Skip to content

Commit

Permalink
fix: sub issue endpoint for state distribution (#1845)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar authored Aug 11, 2023
1 parent abec46a commit 6617049
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,18 +758,16 @@ def get(self, request, slug, project_id, issue_id):
)

state_distribution = (
State.objects.filter(~Q(name="Triage"), workspace__slug=slug)
.annotate(
state_count=Count(
"state_issue",
filter=Q(state_issue__parent_id=issue_id),
)
State.objects.filter(
workspace__slug=slug, state_issue__parent_id=issue_id
)
.order_by("group")
.values("group", "state_count")
.annotate(state_group=F("group"))
.values("state_group")
.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(
sub_issues,
Expand Down

0 comments on commit 6617049

Please sign in to comment.