Skip to content

Commit 3a7d96c

Browse files
committed
backend: update to do filtering for active todos as well
1 parent 4be8b43 commit 3a7d96c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

backend/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class Meta:
5959
def resolve_todos(root, info, **kwargs):
6060
qs = root.todos
6161
status = kwargs.get('status', None)
62-
if status and status == 'completed':
63-
qs = qs.filter(TodoModel.complete == True)
62+
if status and status != 'any':
63+
qs = qs.filter(TodoModel.complete == (status == 'completed'))
6464
return qs.all()
6565

6666
@staticmethod

backend/test_schema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ def test_viewer_query():
8787
}
8888
}
8989
}
90+
activeTodos: todos (status: "active") {
91+
edges {
92+
node {
93+
id
94+
complete
95+
text
96+
}
97+
}
98+
}
9099
}
91100
}
92101
''')
@@ -126,6 +135,11 @@ def test_viewer_query():
126135
completed_todo,
127136
],
128137
},
138+
'activeTodos': {
139+
'edges': [
140+
remaining_todo,
141+
],
142+
},
129143
},
130144
},
131145
}

0 commit comments

Comments
 (0)