From 6a7894811368e025277ce4c5ac392347e0f60924 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Fri, 12 May 2023 12:22:42 +0530 Subject: [PATCH] fix: analytics (#1037) * fix: most issue created by user keys * fix: cycle and module filters for GET method --- apiserver/plane/api/views/analytic.py | 12 ++---------- apiserver/plane/utils/issue_filters.py | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/apiserver/plane/api/views/analytic.py b/apiserver/plane/api/views/analytic.py index 56cb08727..e054678fe 100644 --- a/apiserver/plane/api/views/analytic.py +++ b/apiserver/plane/api/views/analytic.py @@ -1,16 +1,8 @@ # Django imports from django.db.models import ( - Q, Count, Sum, - Value, - Case, - When, - FloatField, - Subquery, - OuterRef, F, - ExpressionWrapper, ) from django.db.models.functions import ExtractMonth @@ -238,8 +230,8 @@ class DefaultAnalyticsEndpoint(BaseAPIView): .order_by("month") ) most_issue_created_user = ( - queryset.filter(created_by__isnull=False) - .values("assignees__email", "assignees__avatar") + queryset.exclude(created_by=None) + .values("created_by__email", "created_by__avatar") .annotate(count=Count("id")) .order_by("-count") )[:5] diff --git a/apiserver/plane/utils/issue_filters.py b/apiserver/plane/utils/issue_filters.py index c9328ecf1..944906f92 100644 --- a/apiserver/plane/utils/issue_filters.py +++ b/apiserver/plane/utils/issue_filters.py @@ -213,7 +213,7 @@ def filter_cycle(params, filter, method): if method == "GET": cycles = params.get("cycle").split(",") if len(cycles) and "" not in cycles: - filter["cycle__in"] = cycles + filter["issue_cycle__cycle_id__in"] = cycles else: if params.get("cycle", None) and len(params.get("cycle")): filter["issue_cycle__cycle_id__in"] = params.get("cycle") @@ -224,7 +224,7 @@ def filter_module(params, filter, method): if method == "GET": modules = params.get("module").split(",") if len(modules) and "" not in modules: - filter["module__in"] = modules + filter["issue_module__module_id__in"] = modules else: if params.get("module", None) and len(params.get("module")): filter["issue_module__module_id__in"] = params.get("module")