From 846e73e3b881d9d31d1fa6bbcab1858f5d61004e Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 22 Mar 2023 01:36:06 +0530 Subject: [PATCH] feat: add issue filters for cycles and modules (#475) --- apiserver/plane/api/views/cycle.py | 4 +++- apiserver/plane/api/views/module.py | 4 +++- apiserver/plane/api/views/view.py | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.py index b87e21f5a..b5f04520b 100644 --- a/apiserver/plane/api/views/cycle.py +++ b/apiserver/plane/api/views/cycle.py @@ -32,6 +32,7 @@ from plane.db.models import ( ) from plane.bgtasks.issue_activites_task import issue_activity from plane.utils.grouper import group_results +from plane.utils.issue_filters import issue_filters class CycleViewSet(BaseViewSet): @@ -143,7 +144,7 @@ class CycleIssueViewSet(BaseViewSet): try: order_by = request.GET.get("order_by", "created_at") group_by = request.GET.get("group_by", False) - + filters = issue_filters(request.query_params, "GET") issues = ( Issue.objects.filter(issue_cycle__cycle_id=cycle_id) .annotate( @@ -162,6 +163,7 @@ class CycleIssueViewSet(BaseViewSet): .prefetch_related("assignees") .prefetch_related("labels") .order_by(order_by) + .filter(**filters) ) issues_data = IssueStateSerializer(issues, many=True).data diff --git a/apiserver/plane/api/views/module.py b/apiserver/plane/api/views/module.py index 43e4ca236..116c37a96 100644 --- a/apiserver/plane/api/views/module.py +++ b/apiserver/plane/api/views/module.py @@ -32,6 +32,7 @@ from plane.db.models import ( ) from plane.bgtasks.issue_activites_task import issue_activity from plane.utils.grouper import group_results +from plane.utils.issue_filters import issue_filters class ModuleViewSet(BaseViewSet): @@ -156,7 +157,7 @@ class ModuleIssueViewSet(BaseViewSet): try: order_by = request.GET.get("order_by", "created_at") group_by = request.GET.get("group_by", False) - + filters = issue_filters(request.query_params, "GET") issues = ( Issue.objects.filter(issue_module__module_id=module_id) .annotate( @@ -175,6 +176,7 @@ class ModuleIssueViewSet(BaseViewSet): .prefetch_related("assignees") .prefetch_related("labels") .order_by(order_by) + .filter(**filters) ) issues_data = IssueStateSerializer(issues, many=True).data diff --git a/apiserver/plane/api/views/view.py b/apiserver/plane/api/views/view.py index 6c4241d7e..f03866cfa 100644 --- a/apiserver/plane/api/views/view.py +++ b/apiserver/plane/api/views/view.py @@ -24,6 +24,7 @@ from plane.db.models import ( ModuleIssue, IssueViewFavorite, ) +from plane.utils.issue_filters import issue_filters class IssueViewViewSet(BaseViewSet): @@ -66,10 +67,13 @@ class ViewIssuesEndpoint(BaseAPIView): view = IssueView.objects.get(pk=view_id) queries = view.query + filters = issue_filters(request.query_params, "GET") + issues = ( Issue.objects.filter( **queries, project_id=project_id, workspace__slug=slug ) + .filter(**filters) .select_related("project") .select_related("workspace") .select_related("state")