From 85b6c78e7510ff82dbee39292042c3b069210e96 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Mon, 17 Apr 2023 14:03:19 +0530 Subject: [PATCH] chore: my issues endpoint to return attachment and link count --- apiserver/plane/api/views/issue.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index 963115c96..1f604d271 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -246,6 +246,20 @@ class UserWorkSpaceIssues(BaseAPIView): .prefetch_related("assignees") .prefetch_related("labels") .order_by("-created_at") + .annotate( + link_count=IssueLink.objects.filter(issue=OuterRef("id")) + .order_by() + .annotate(count=Func(F("id"), function="Count")) + .values("count") + ) + .annotate( + attachment_count=IssueAttachment.objects.filter( + issue=OuterRef("id") + ) + .order_by() + .annotate(count=Func(F("id"), function="Count")) + .values("count") + ) ) serializer = IssueLiteSerializer(issues, many=True) return Response(serializer.data, status=status.HTTP_200_OK)