Skip to content

Commit

Permalink
Filter out non-section to-dos (#763)
Browse files Browse the repository at this point in the history
* Filter out non-section to-dos

* Update orchestra/static/orchestra/todos/todo-list.directive.es6.js

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>

* Update main.js

* Fix linting

* Fix linting

Co-authored-by: Aditya Bharadwaj <aditya@b12.io>
Co-authored-by: Adam Marcus <marcua@marcua.net>
  • Loading branch information
3 people committed Mar 27, 2021
1 parent 321a56c commit 6f2f4d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
7 changes: 6 additions & 1 deletion orchestra/static/dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66751,7 +66751,12 @@ function todoList(orchestraApi) {

todoList.transformToTree = function (todos) {
var nodes = {};
return todos.filter(function (obj) {
// TODO(aditya): Temporarily we are filtering out todos
// with section values. Remove this comment once we
// figure out a long term logic
return todos.filter(function (todo) {
return !todo.section;
}).filter(function (obj) {
nodes[obj.id] = (0, _lodash.defaults)(obj, nodes[obj.id], { items: [] });
obj.parent_todo && (nodes[obj.parent_todo] = nodes[obj.parent_todo] || { items: [] })['items'].push(obj);

Expand Down
5 changes: 4 additions & 1 deletion orchestra/static/orchestra/todos/todo-list.directive.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ export default function todoList (orchestraApi) {

todoList.transformToTree = (todos) => {
var nodes = {}
return todos.filter(function (obj) {
// TODO(aditya): Temporarily we are filtering out todos
// with section values. Remove this comment once we
// figure out a long term logic
return todos.filter(todo => !todo.section).filter(function (obj) {
nodes[obj.id] = defaults(obj, nodes[obj.id], { items: [] })
obj.parent_todo && (nodes[obj.parent_todo] = (nodes[obj.parent_todo] || { items: [] }))['items'].push(obj)

Expand Down
15 changes: 12 additions & 3 deletions orchestra/utils/task_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from orchestra.models import Iteration
from orchestra.models import Project
from orchestra.models import Task
from orchestra.models import Todo
from orchestra.models import TaskAssignment
from orchestra.models import Worker
from orchestra.models import WorkerCertification
Expand Down Expand Up @@ -548,11 +549,15 @@ def tasks_assigned_to_worker(worker):
next_todo_dict = {}
should_be_active = False
if state in ('returned', 'in_progress'):
# TODO(aditya): Temporarily we are filtering out todos
# with section values. Remove this comment once we
# figure out a long term logic.
next_todo = (
task_assignment.task.todos
.filter(
completed=False,
template=None
status=Todo.Status.PENDING.value,
template=None,
section__isnull=True
).annotate(
todo_order=Case(
When(
Expand Down Expand Up @@ -590,9 +595,13 @@ def tasks_assigned_to_worker(worker):
'start_by_datetime': start_str,
'due_datetime': due_str
}
# TODO(aditya): Temporarily we are filtering out todos
# with section values. Remove this comment once we
# figure out a long term logic.
num_non_template_todos = (
task_assignment.task.todos
.filter(template=None).count())
.filter(template=None,
section__isnull=True).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 6f2f4d8

Please sign in to comment.