diff --git a/apiserver/plane/bgtasks/analytic_plot_export.py b/apiserver/plane/bgtasks/analytic_plot_export.py index a041fd169..a80770c37 100644 --- a/apiserver/plane/bgtasks/analytic_plot_export.py +++ b/apiserver/plane/bgtasks/analytic_plot_export.py @@ -408,7 +408,6 @@ def analytic_export_task(email, data, slug): distribution, x_axis, y_axis, - segment, key, assignee_details, label_details, diff --git a/apiserver/plane/utils/analytics_plot.py b/apiserver/plane/utils/analytics_plot.py index 259ab4b63..be52bcce4 100644 --- a/apiserver/plane/utils/analytics_plot.py +++ b/apiserver/plane/utils/analytics_plot.py @@ -12,19 +12,19 @@ from django.db.models.functions import Coalesce, ExtractMonth, ExtractYear, Conc from plane.db.models import Issue -def annotate_with_monthly_dimension(queryset, field_name): +def annotate_with_monthly_dimension(queryset, field_name, attribute): # Get the year and the months year = ExtractYear(field_name) month = ExtractMonth(field_name) # Concat the year and month dimension = Concat(year, Value("-"), month, output_field=CharField()) # Annotate the dimension - return queryset.annotate(dimension=dimension) + return queryset.annotate(**{attribute: dimension}) def extract_axis(queryset, x_axis): # Format the dimension when the axis is in date if x_axis in ["created_at", "start_date", "target_date", "completed_at"]: - queryset = annotate_with_monthly_dimension(queryset, x_axis) + queryset = annotate_with_monthly_dimension(queryset, x_axis, "dimension") return queryset, "dimension" else: return queryset.annotate(dimension=F(x_axis)), "dimension" @@ -47,7 +47,7 @@ def build_graph_plot(queryset, x_axis, y_axis, segment=None): # if segment in ["created_at", "start_date", "target_date", "completed_at"]: - queryset = annotate_with_monthly_dimension(queryset, segment) + queryset = annotate_with_monthly_dimension(queryset, segment, "segmented") segment = "segmented" queryset = queryset.values(x_axis)