Skip to content

Commit

Permalink
Fix dashboard to handle todo sections with empty strings as null value (
Browse files Browse the repository at this point in the history
#766)

* Fix dashboard to handle sections with empty strings as null value

* Update orchestra/utils/task_lifecycle.py

Co-authored-by: Adam Marcus <marcua@marcua.net>

* Update orchestra/utils/task_lifecycle.py

Co-authored-by: Adam Marcus <marcua@marcua.net>

* Update orchestra/utils/task_lifecycle.py

Co-authored-by: Adam Marcus <marcua@marcua.net>

* Use template__isnull

Co-authored-by: Aditya Bharadwaj <aditya@b12.io>
Co-authored-by: Adam Marcus <marcua@marcua.net>
  • Loading branch information
3 people committed Mar 31, 2021
1 parent 6940fec commit 2e5e0d6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions orchestra/utils/task_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ def tasks_assigned_to_worker(worker):

tasks_assigned = []
time_now = timezone.now()
pending_todos_filter = Q(status=Todo.Status.PENDING.value)
non_template_todo_filter = Q(template__isnull=True)
no_section_todo_filter = Q(section__isnull=True) | Q(section='')
for state, task_assignments in iter(task_assignments_overview.items()):
for task_assignment in task_assignments:
step = task_assignment.task.step
Expand All @@ -555,9 +558,9 @@ def tasks_assigned_to_worker(worker):
next_todo = (
task_assignment.task.todos
.filter(
status=Todo.Status.PENDING.value,
template=None,
section__isnull=True
pending_todos_filter &
non_template_todo_filter &
no_section_todo_filter
).annotate(
todo_order=Case(
When(
Expand Down Expand Up @@ -600,8 +603,10 @@ def tasks_assigned_to_worker(worker):
# figure out a long term logic.
num_non_template_todos = (
task_assignment.task.todos
.filter(template=None,
section__isnull=True).count())
.filter(
non_template_todo_filter &
no_section_todo_filter
).count())
# If a task has no todos (complete or incomplete)
# assigned to it, then by default the task would be
# marked as pending. When a task is first created and
Expand Down

0 comments on commit 2e5e0d6

Please sign in to comment.