diff --git a/apiserver/plane/app/views/cycle/base.py b/apiserver/plane/app/views/cycle/base.py index ccc8087be..d36c36dd5 100644 --- a/apiserver/plane/app/views/cycle/base.py +++ b/apiserver/plane/app/views/cycle/base.py @@ -819,7 +819,11 @@ class CycleIssueViewSet(WebhookMixin, BaseViewSet): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -855,7 +859,11 @@ class CycleIssueViewSet(WebhookMixin, BaseViewSet): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/app/views/issue/archive.py b/apiserver/plane/app/views/issue/archive.py index fe8265723..f9c59b928 100644 --- a/apiserver/plane/app/views/issue/archive.py +++ b/apiserver/plane/app/views/issue/archive.py @@ -142,7 +142,11 @@ class IssueArchiveViewSet(BaseViewSet): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -178,7 +182,11 @@ class IssueArchiveViewSet(BaseViewSet): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/app/views/issue/base.py b/apiserver/plane/app/views/issue/base.py index 8d1bad4f5..59feccd4d 100644 --- a/apiserver/plane/app/views/issue/base.py +++ b/apiserver/plane/app/views/issue/base.py @@ -142,7 +142,11 @@ class IssueListEndpoint(BaseAPIView): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -178,7 +182,11 @@ class IssueListEndpoint(BaseAPIView): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -308,7 +316,11 @@ class IssueViewSet(WebhookMixin, BaseViewSet): else: return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -343,7 +355,11 @@ class IssueViewSet(WebhookMixin, BaseViewSet): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/app/views/issue/draft.py b/apiserver/plane/app/views/issue/draft.py index 181920e5d..24b8b08e0 100644 --- a/apiserver/plane/app/views/issue/draft.py +++ b/apiserver/plane/app/views/issue/draft.py @@ -129,7 +129,11 @@ class IssueDraftViewSet(BaseViewSet): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -165,7 +169,11 @@ class IssueDraftViewSet(BaseViewSet): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/app/views/module/base.py b/apiserver/plane/app/views/module/base.py index 48bdea1dd..0c47c928e 100644 --- a/apiserver/plane/app/views/module/base.py +++ b/apiserver/plane/app/views/module/base.py @@ -543,7 +543,11 @@ class ModuleIssueViewSet(WebhookMixin, BaseViewSet): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -579,7 +583,11 @@ class ModuleIssueViewSet(WebhookMixin, BaseViewSet): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/app/views/view/base.py b/apiserver/plane/app/views/view/base.py index 65b474170..d813414e4 100644 --- a/apiserver/plane/app/views/view/base.py +++ b/apiserver/plane/app/views/view/base.py @@ -188,7 +188,11 @@ class GlobalViewIssuesViewSet(BaseViewSet): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -224,7 +228,11 @@ class GlobalViewIssuesViewSet(BaseViewSet): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/space/views/issue.py b/apiserver/plane/space/views/issue.py index d410c0318..92653f721 100644 --- a/apiserver/plane/space/views/issue.py +++ b/apiserver/plane/space/views/issue.py @@ -592,7 +592,11 @@ class ProjectIssuesPublicEndpoint(BaseAPIView): # group and sub group pagination return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, @@ -628,7 +632,11 @@ class ProjectIssuesPublicEndpoint(BaseAPIView): # Group paginate return self.paginate( request=request, - order_by=order_by_param, + order_by=( + "priority_order" + if order_by_param in ["priority", "-priority"] + else order_by_param + ), queryset=issue_queryset, on_results=lambda issues: issue_on_results( group_by=group_by, diff --git a/apiserver/plane/utils/grouper.py b/apiserver/plane/utils/grouper.py index 5489683ae..b6bc1a347 100644 --- a/apiserver/plane/utils/grouper.py +++ b/apiserver/plane/utils/grouper.py @@ -26,8 +26,8 @@ def issue_queryset_grouper(queryset, group_by, sub_group_by): } annotations_map = { - "label_ids": ("assignees__id", ~Q(assignees__id__isnull=True)), - "assignee_ids": ("labels__id", ~Q(labels__id__isnull=True)), + "assignee_ids": ("assignees__id", ~Q(assignees__id__isnull=True)), + "label_ids": ("labels__id", ~Q(labels__id__isnull=True)), "module_ids": ( "issue_module__module_id", ~Q(issue_module__module_id__isnull=True),