From 27626fb16ffabef9573527cae2b66e75f5f31e44 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 17 May 2023 14:58:45 +0530 Subject: [PATCH] fix: default analytic estimate points and sorting for custom analytics (#1066) --- apiserver/plane/api/views/analytic.py | 6 ++++-- apiserver/plane/utils/analytics_plot.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apiserver/plane/api/views/analytic.py b/apiserver/plane/api/views/analytic.py index 28ffceab7..56ca12bae 100644 --- a/apiserver/plane/api/views/analytic.py +++ b/apiserver/plane/api/views/analytic.py @@ -261,11 +261,13 @@ class DefaultAnalyticsEndpoint(BaseAPIView): ) open_estimate_sum = ( - Issue.objects.filter( + queryset.filter( state__group__in=["backlog", "unstarted", "started"] ).aggregate(open_estimate_sum=Sum("estimate_point")) )["open_estimate_sum"] - total_estimate_sum = Issue.objects.aggregate( + print(open_estimate_sum) + + total_estimate_sum = queryset.aggregate( total_estimate_sum=Sum("estimate_point") )["total_estimate_sum"] diff --git a/apiserver/plane/utils/analytics_plot.py b/apiserver/plane/utils/analytics_plot.py index 10b0a799d..161f6497e 100644 --- a/apiserver/plane/utils/analytics_plot.py +++ b/apiserver/plane/utils/analytics_plot.py @@ -72,5 +72,5 @@ def build_graph_plot(queryset, x_axis, y_axis, segment=None): order = ["low", "medium", "high", "urgent", "None"] sorted_data = {key: grouped_data[key] for key in order if key in grouped_data} else: - sorted_data = dict(sorted(grouped_data.items(), key=lambda x: (x[0] is "None", x[0]))) + sorted_data = dict(sorted(grouped_data.items(), key=lambda x: (x[0] == "None", x[0]))) return sorted_data