From edaeae1b6989ac4cb93f9046fbda278073c217f7 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:48:02 +0530 Subject: [PATCH] chore: sort order for cycle and modules (#1835) --- apiserver/plane/api/views/cycle.py | 3 +++ apiserver/plane/api/views/module.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.py index 885199f83..a3d89fa81 100644 --- a/apiserver/plane/api/views/cycle.py +++ b/apiserver/plane/api/views/cycle.py @@ -165,6 +165,9 @@ class CycleViewSet(BaseViewSet): try: queryset = self.get_queryset() cycle_view = request.GET.get("cycle_view", "all") + order_by = request.GET.get("order_by", "sort_order") + + queryset = queryset.order_by(order_by) # All Cycles if cycle_view == "all": diff --git a/apiserver/plane/api/views/module.py b/apiserver/plane/api/views/module.py index 7d60456a0..1cd741f84 100644 --- a/apiserver/plane/api/views/module.py +++ b/apiserver/plane/api/views/module.py @@ -53,6 +53,8 @@ class ModuleViewSet(BaseViewSet): ) def get_queryset(self): + order_by = self.request.GET.get("order_by", "sort_order") + subquery = ModuleFavorite.objects.filter( user=self.request.user, module_id=OuterRef("pk"), @@ -106,7 +108,7 @@ class ModuleViewSet(BaseViewSet): filter=Q(issue_module__issue__state__group="backlog"), ) ) - .order_by("-is_favorite", "name") + .order_by(order_by, "name") ) def perform_destroy(self, instance):