Skip to content

Commit eb14dfd

Browse files
thenav56szabozoltan69
authored andcommitted
feat: define ordering for RegionProjectViewset.projects_by_status
1 parent 6a5fbf4 commit eb14dfd

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

deployments/drf_views.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,13 @@ def overview(self, request, pk=None):
681681
"total_budget": aggregate_data["total_budget"],
682682
"target_total": aggregate_data["target_total"],
683683
"reached_total": aggregate_data["reached_total"],
684-
"projects_by_status": projects.order_by()
685-
.values("status")
686-
.annotate(count=models.Count("id", distinct=True))
687-
.values("status", "count"),
684+
"projects_by_status": (
685+
projects.order_by()
686+
.values("status")
687+
.annotate(count=models.Count("id", distinct=True))
688+
.values("status", "count")
689+
.order_by("status", "count")
690+
),
688691
}
689692
return Response(data)
690693

deployments/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def test_regional_project_get(self, mock_now):
332332
"total_budget": 109102,
333333
"target_total": 31000,
334334
"reached_total": 9054,
335-
"projects_by_status": [{"count": 2, "status": 1}, {"count": 3, "status": 0}, {"count": 3, "status": 2}],
335+
"projects_by_status": [{"status": 0, "count": 3}, {"status": 1, "count": 2}, {"status": 2, "count": 3}],
336336
},
337337
resp.json(),
338338
)

0 commit comments

Comments
 (0)