Esri / Esri/workforce-scripts

Optimally Creating and Assigning Work Orders Based on Routes

Open
#99 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
85
Forks
62
PR merge metrics
No merged PRs in 30d

Description

Hello,
In the **'Optimally Creating and Assigning Work Orders Based on Routes'** notebook there is the following code:

```
assignments_to_add = []
for _, row in routes.iterrows():
worker = random.choice(workers)
workers.remove(worker)
route_stops = stops.loc[(stops['RouteName'] == row["RouteName"]) & stops['globalid'].notnull()]
for _, stop in route_stops.iterrows():
assignments_to_add.append(workforce.Assignment(
project,
assignment_type="Inspection",
location=stop["name"],
status="assigned",
worker=worker,
assigned_date=datetime.now(),
due_date=stop["DepartTime"],
geometry=stop["SHAPE"]
))
assignments = project.assignments.batch_add(assignments_to_add)
```

I think the line **workers.remove(worker)** should be removed because then in **assignments_to_add.append()** the **worker=worker** will give an error of empty list. Am I wrong?

Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.