Skip to content

Commit fc38fa6

Browse files
committed
feat(project): Set default filtering on project and tutorial
1 parent a05ccb9 commit fc38fa6

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

apps/project/graphql/queries.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,10 @@ def projects(
9898
) -> QuerySet[Project]:
9999
if include_all:
100100
return Project.objects.all()
101-
return Project.objects.exclude(status__in=[Project.Status.ARCHIVED, Project.Status.DISCARDED]).all()
101+
return Project.objects.filter(
102+
status__in=[
103+
Project.Status.READY,
104+
Project.Status.PUBLISHED,
105+
Project.Status.PAUSED,
106+
],
107+
).all()

apps/project/tests/query_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class Query:
5757
credits
5858
}
5959
}
60-
query Projects($pagination: OffsetPaginationInput) {
61-
projects(order: {id: ASC}, pagination: $pagination) {
60+
query Projects($pagination: OffsetPaginationInput, $includeAll: Boolean = false) {
61+
projects(order: {id: ASC}, pagination: $pagination, includeAll: $includeAll) {
6262
totalCount
6363
pageInfo {
6464
offset
@@ -305,6 +305,7 @@ def _query():
305305
"limit": 10,
306306
"offset": 0,
307307
},
308+
"includeAll": True,
308309
},
309310
)
310311

apps/tutorial/graphql/queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def tutorials(
2929
) -> QuerySet[Tutorial]:
3030
if include_all:
3131
return Tutorial.objects.all()
32-
return Tutorial.objects.exclude(status__in=[Tutorial.Status.ARCHIVED, Tutorial.Status.DISCARDED]).all()
32+
return Tutorial.objects.filter(status=Tutorial.Status.PUBLISHED).all()

0 commit comments

Comments
 (0)