From c3d520aefda98492296eb897d56ae8471a1c5056 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 17 May 2023 18:32:10 +0530 Subject: [PATCH] fix: analytics segmented export (#1068) * fix: analytics segmented export * dev: fix none type * fix: analytic export y axis count --- apiserver/plane/bgtasks/analytic_plot_export.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apiserver/plane/bgtasks/analytic_plot_export.py b/apiserver/plane/bgtasks/analytic_plot_export.py index 67df70792..ad4b76d5f 100644 --- a/apiserver/plane/bgtasks/analytic_plot_export.py +++ b/apiserver/plane/bgtasks/analytic_plot_export.py @@ -65,20 +65,22 @@ def analytic_export_task(email, data, slug): ] + segment_zero ) - rows = [] for item in distribution: generated_row = [ item, ] + data = distribution.get(item) - for segment in segment_zero[1:]: + # Add y axis values + generated_row.append(sum(obj.get(key) for obj in data if obj.get(key, None) is not None)) + + for segment in segment_zero: value = [x for x in data if x.get("segment") == segment] if len(value): generated_row.append(value[0].get(key)) else: generated_row.append("0") - rows.append(tuple(generated_row)) rows = [tuple(row_zero)] + rows @@ -114,7 +116,7 @@ def analytic_export_task(email, data, slug): item, distribution.get(item)[0].get("count") if y_axis == "issue_count" - else distribution.get(item)[0].get("estimate"), + else distribution.get(item)[0].get("estimate "), ] ) )