fix: sub issue endpoint for state distribution (#1845)

This commit is contained in:
Nikhil 2023-08-11 16:38:03 +05:30 committed by GitHub
parent abec46a725
commit 6617049983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -758,18 +758,16 @@ class SubIssuesEndpoint(BaseAPIView):
) )
state_distribution = ( state_distribution = (
State.objects.filter(~Q(name="Triage"), workspace__slug=slug) State.objects.filter(
.annotate( workspace__slug=slug, state_issue__parent_id=issue_id
state_count=Count(
"state_issue",
filter=Q(state_issue__parent_id=issue_id),
) )
) .annotate(state_group=F("group"))
.order_by("group") .values("state_group")
.values("group", "state_count") .annotate(state_count=Count("state_group"))
.order_by("state_group")
) )
result = {item["group"]: item["state_count"] for item in state_distribution} result = {item["state_group"]: item["state_count"] for item in state_distribution}
serializer = IssueLiteSerializer( serializer = IssueLiteSerializer(
sub_issues, sub_issues,