Skip to content

Commit af5e80d

Browse files
thenav56szabozoltan69
authored andcommitted
feat: define ordering for RegionProjectViewset.projects_by_status
1 parent e1e85fd commit af5e80d

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
@@ -615,10 +615,13 @@ def overview(self, request, pk=None):
615615
"total_budget": aggregate_data["total_budget"],
616616
"target_total": aggregate_data["target_total"],
617617
"reached_total": aggregate_data["reached_total"],
618-
"projects_by_status": projects.order_by()
619-
.values("status")
620-
.annotate(count=models.Count("id", distinct=True))
621-
.values("status", "count"),
618+
"projects_by_status": (
619+
projects.order_by()
620+
.values("status")
621+
.annotate(count=models.Count("id", distinct=True))
622+
.values("status", "count")
623+
.order_by("status", "count")
624+
),
622625
}
623626
return Response(data)
624627

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)