From 2f44d4803d315c12194bc721a7f00e678269dea5 Mon Sep 17 00:00:00 2001 From: Mia Miu Date: Thu, 4 Jun 2026 17:04:40 +1200 Subject: [PATCH] fix: use module names in analytics export headers --- .../api/plane/bgtasks/analytic_plot_export.py | 2 +- .../bg_tasks/test_analytic_plot_export.py | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 apps/api/plane/tests/unit/bg_tasks/test_analytic_plot_export.py diff --git a/apps/api/plane/bgtasks/analytic_plot_export.py b/apps/api/plane/bgtasks/analytic_plot_export.py index 4b0983138be..bf17d995693 100644 --- a/apps/api/plane/bgtasks/analytic_plot_export.py +++ b/apps/api/plane/bgtasks/analytic_plot_export.py @@ -277,7 +277,7 @@ def generate_segmented_rows( if segmented == MODULE_ID: for index, segm in enumerate(row_zero[2:]): - module = next((mod for mod in label_details if str(mod[MODULE_ID]) == str(segm)), None) + module = next((mod for mod in module_details if str(mod[MODULE_ID]) == str(segm)), None) if module: row_zero[index + 2] = module["issue_module__module__name"] diff --git a/apps/api/plane/tests/unit/bg_tasks/test_analytic_plot_export.py b/apps/api/plane/tests/unit/bg_tasks/test_analytic_plot_export.py new file mode 100644 index 00000000000..015c37a04ea --- /dev/null +++ b/apps/api/plane/tests/unit/bg_tasks/test_analytic_plot_export.py @@ -0,0 +1,41 @@ +# Copyright (c) 2023-present Plane Software, Inc. and contributors +# SPDX-License-Identifier: AGPL-3.0-only +# See the LICENSE file for details. + +import pytest + +from plane.bgtasks.analytic_plot_export import ( + MODULE_ID, + generate_segmented_rows, +) + + +@pytest.mark.unit +class TestGenerateSegmentedRows: + def test_module_segment_headers_use_module_names(self): + rows = generate_segmented_rows( + distribution={ + "High": [ + { + "segment": "module-1", + "issue_count": 3, + } + ] + }, + x_axis="priority", + y_axis="issue_count", + segment=MODULE_ID, + key="issue_count", + assignee_details=[], + label_details=[], + state_details=[], + cycle_details=[], + module_details=[ + { + MODULE_ID: "module-1", + "issue_module__module__name": "Launch Plan", + } + ], + ) + + assert rows[0] == ("Priority", "Issue Count", "Launch Plan")