From df46a45afcfd0c01a38de2ab9bbd8b38bd6f043b Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:48:22 +0530 Subject: [PATCH] fix: analytics export (#1862) * fix: analytics export * dev: export analytics assignee indexing * dev: total counts --- .../plane/bgtasks/analytic_plot_export.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apiserver/plane/bgtasks/analytic_plot_export.py b/apiserver/plane/bgtasks/analytic_plot_export.py index 3177c39fe..492be8870 100644 --- a/apiserver/plane/bgtasks/analytic_plot_export.py +++ b/apiserver/plane/bgtasks/analytic_plot_export.py @@ -51,12 +51,12 @@ def analytic_export_task(email, data, slug): segmented = segment assignee_details = {} - if x_axis in ["assignees__display_name"] or segment in ["assignees__display_name"]: + if x_axis in ["assignees__id"] or segment in ["assignees__id"]: assignee_details = ( Issue.issue_objects.filter(workspace__slug=slug, **filters, assignees__avatar__isnull=False) .order_by("assignees__id") .distinct("assignees__id") - .values("assignees__avatar", "assignees__display_name", "assignees__first_name", "assignees__last_name") + .values("assignees__avatar", "assignees__display_name", "assignees__first_name", "assignees__last_name", "assignees__id") ) if segment: @@ -93,19 +93,19 @@ def analytic_export_task(email, data, slug): else: generated_row.append("0") # x-axis replacement for names - if x_axis in ["assignees__display_name"]: - assignee = [user for user in assignee_details if str(user.get("assignees__display_name")) == str(item)] + if x_axis in ["assignees__id"]: + assignee = [user for user in assignee_details if str(user.get("assignees__id")) == str(item)] if len(assignee): generated_row[0] = str(assignee[0].get("assignees__first_name")) + " " + str(assignee[0].get("assignees__last_name")) rows.append(tuple(generated_row)) # If segment is ["assignees__display_name"] then replace segment_zero rows with first and last names - if segmented in ["assignees__display_name"]: + if segmented in ["assignees__id"]: for index, segm in enumerate(row_zero[2:]): # find the name of the user - assignee = [user for user in assignee_details if str(user.get("assignees__display_name")) == str(segm)] + assignee = [user for user in assignee_details if str(user.get("assignees__id")) == str(segm)] if len(assignee): - row_zero[index] = str(assignee[0].get("assignees__first_name")) + " " + str(assignee[0].get("assignees__last_name")) + row_zero[index + 2] = str(assignee[0].get("assignees__first_name")) + " " + str(assignee[0].get("assignees__last_name")) rows = [tuple(row_zero)] + rows csv_buffer = io.StringIO() @@ -141,8 +141,8 @@ def analytic_export_task(email, data, slug): else distribution.get(item)[0].get("estimate "), ] # x-axis replacement to names - if x_axis in ["assignees__display_name"]: - assignee = [user for user in assignee_details if str(user.get("assignees__display_name")) == str(item)] + if x_axis in ["assignees__id"]: + assignee = [user for user in assignee_details if str(user.get("assignees__id")) == str(item)] if len(assignee): row[0] = str(assignee[0].get("assignees__first_name")) + " " + str(assignee[0].get("assignees__last_name"))