From f68e6023c3fcb01cc233b31d59fef2523cb2a0a3 Mon Sep 17 00:00:00 2001 From: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Date: Fri, 19 Jan 2024 15:17:49 +0530 Subject: [PATCH] fix: user profile issues (#3409) --- apiserver/plane/app/views/workspace.py | 30 +++++++++++--------------- apiserver/plane/db/models/module.py | 24 ++++++++++----------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/apiserver/plane/app/views/workspace.py b/apiserver/plane/app/views/workspace.py index 9cedff8f4..ec878bcb0 100644 --- a/apiserver/plane/app/views/workspace.py +++ b/apiserver/plane/app/views/workspace.py @@ -41,7 +41,7 @@ from plane.app.serializers import ( ProjectMemberSerializer, WorkspaceThemeSerializer, IssueActivitySerializer, - IssueLiteSerializer, + IssueSerializer, WorkspaceMemberAdminSerializer, WorkspaceMemberMeSerializer, ProjectMemberRoleSerializer, @@ -1339,23 +1339,10 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView): project__project_projectmember__member=request.user, ) .filter(**filters) - .annotate( - sub_issues_count=Issue.issue_objects.filter( - parent=OuterRef("id") - ) - .order_by() - .annotate(count=Func(F("id"), function="Count")) - .values("count") - ) - .select_related("project", "workspace", "state", "parent") + .select_related("workspace", "project", "state", "parent") .prefetch_related("assignees", "labels") - .prefetch_related( - Prefetch( - "issue_reactions", - queryset=IssueReaction.objects.select_related("actor"), - ) - ) - .order_by("-created_at") + .annotate(cycle_id=F("issue_cycle__cycle_id")) + .annotate(module_id=F("issue_module__module_id")) .annotate( link_count=IssueLink.objects.filter(issue=OuterRef("id")) .order_by() @@ -1370,6 +1357,13 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView): .annotate(count=Func(F("id"), function="Count")) .values("count") ) + .annotate( + sub_issues_count=Issue.issue_objects.filter(parent=OuterRef("id")) + .order_by() + .annotate(count=Func(F("id"), function="Count")) + .values("count") + ) + .order_by("created_at") ).distinct() # Priority Ordering @@ -1432,7 +1426,7 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView): else: issue_queryset = issue_queryset.order_by(order_by_param) - issues = IssueLiteSerializer( + issues = IssueSerializer( issue_queryset, many=True, fields=fields if fields else None ).data return Response(issues, status=status.HTTP_200_OK) diff --git a/apiserver/plane/db/models/module.py b/apiserver/plane/db/models/module.py index 1a47aac1b..131af5e1c 100644 --- a/apiserver/plane/db/models/module.py +++ b/apiserver/plane/db/models/module.py @@ -7,19 +7,17 @@ from . import ProjectBaseModel def get_default_filters(): - return ( - { - "priority": None, - "state": None, - "state_group": None, - "assignees": None, - "created_by": None, - "labels": None, - "start_date": None, - "target_date": None, - "subscriber": None, - }, - ) + return { + "priority": None, + "state": None, + "state_group": None, + "assignees": None, + "created_by": None, + "labels": None, + "start_date": None, + "target_date": None, + "subscriber": None, + } def get_default_display_filters():