Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the todos dashboard bugs #535

Merged
merged 4 commits into from Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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