Skip to content

Commit

Permalink
Fix the todos dashboard bugs (#535)
Browse files Browse the repository at this point in the history
* Make it possible to log time for pending tasks

* Only mark a task as not new if there is non-templated task

* Fix lint errors

* Fix lint errors
  • Loading branch information
paopow authored and Aditya Bharadwaj committed Jan 22, 2021
1 parent 9d8e1f6 commit 7799bae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Expand Up @@ -112,10 +112,10 @@ export function orchestraTasks ($http) {
pendingTasks: function () { return this.allTasks().filter(task => pendingTask(task)) },
pausedTasks: function () { return this.allTasks().filter(task => pausedTask(task)) },
completedTasks: function () { return this.allTasks().filter(task => task.state === 'complete') },
activeAndRecentTasks: function (numRecent) {
// Return all active tasks, as well as `numRecent` of the most
activePendingAndRecentTasks: function (numRecent) {
// Return all active tasks, pending tasks, as well as `numRecent` of the most
// recently completed tasks.
var tasks = this.activeTasks()
var tasks = this.activeTasks().concat(this.pendingTasks())
return tasks.concat(this.completedTasks().slice(0, numRecent))
},
getDescription: function (task) {
Expand Down
Expand Up @@ -3,7 +3,7 @@
<ui-select-match>
<span ng-bind="taskSelect.orchestraTasks.getDescription($select.selected)"></span>
</ui-select-match>
<ui-select-choices repeat="item in (taskSelect.orchestraTasks.activeAndRecentTasks(5) | filter: $select.search) track by item.id">
<ui-select-choices repeat="item in (taskSelect.orchestraTasks.activePendingAndRecentTasks(5) | filter: $select.search) track by item.id">
<span ng-bind="taskSelect.orchestraTasks.getDescription(item)"></span>
</ui-select-choices>
</ui-select>
8 changes: 6 additions & 2 deletions orchestra/utils/task_lifecycle.py
Expand Up @@ -588,7 +588,9 @@ def tasks_assigned_to_worker(worker):
'start_by_datetime': start_str,
'due_datetime': due_str
}
num_todos = task_assignment.task.todos.count()
num_non_template_todos = (
task_assignment.task.todos
.filter(template=None).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 All @@ -605,7 +607,9 @@ def tasks_assigned_to_worker(worker):
or next_todo.start_by_datetime <= time_now
)
)
should_be_active = (num_todos == 0) or task_started
should_be_active = (
(num_non_template_todos == 0)
or task_started)
tasks_assigned.append({
'id': task_assignment.task.id,
'assignment_id': task_assignment.id,
Expand Down

0 comments on commit 7799bae

Please sign in to comment.