Skip to content

Commit

Permalink
Deduplicate tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Feb 20, 2021
1 parent a1e47c8 commit ddcea01
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions orchestra/communication/staffing.py
Expand Up @@ -188,12 +188,16 @@ def _can_handle_more_work_today(worker, task):
created_at__gte=today,
created_at__lt=today + timedelta(days=1)
)
hours_assigned = [
# Create a dictionary to deduplicate tasks if a Worker is
# reassigned the same task multiple times.
hours_assigned = {
response.request_inquiry.request.task.id:
(response.request_inquiry.request.task.get_assignable_hours(),
response.request_inquiry.request.task)
for response in responses]
for response in responses
}
hours_assigned = [
(hours, task) for (hours, task) in hours_assigned
(hours, task) for (hours, task) in hours_assigned.values()
if hours is not None]
max_tasks = settings.ORCHESTRA_MAX_AUTOSTAFF_TASKS_PER_DAY
# To estimate how much someone worked today, we add:
Expand Down

0 comments on commit ddcea01

Please sign in to comment.