From fdc8b3953a83872ae1828cdcc4250e69bd3561a4 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Sun, 30 Nov 2025 21:25:34 +0000 Subject: [PATCH] save to main --- backend/src/dashboard/main.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/backend/src/dashboard/main.py b/backend/src/dashboard/main.py index 760ebbb..b0dac4f 100644 --- a/backend/src/dashboard/main.py +++ b/backend/src/dashboard/main.py @@ -9,6 +9,9 @@ from backend.src.dashboard.services.file_manager import FileManager from backend.src.dashboard.services.json_reader import jsonReader from backend.src.dashboard.components.pivot_charts import build_pivot_tables_and_charts, week_start_monday +# from dashboard.services.file_manager import FileManager +# from dashboard.services.json_reader import jsonReader +# from dashboard.components.pivot_charts import build_pivot_tables_and_charts, week_start_monday SAFE_DELIM = "\\\\" @@ -257,15 +260,31 @@ def open_modal(jobs_cell, revenue_cell, close_click, jobs_data, revenue_data, is # ------------------------- def build_modal(row, col_id): - if "_" not in col_id: - return html.P("No HubSpot IDs for this column.") + # Ignore columns like "Product Type" + if col_id == "Product Type": + return html.P("This column has no IDs.") - week, side = col_id.split("_", 1) + # ---------------------------------------------------- + # 1. Detect week + # ---------------------------------------------------- + parts = col_id.split(" ") - side_lower = side.lower() + # Revenue columns = 3 parts → ["2025-02-05", "Planned", "£"] + # Jobs columns = 2 parts → ["2025-02-05_Planned", "Jobs"] + if "_" in parts[0]: + # Jobs table format: 2025-02-05_Planned + week = parts[0].split("_")[0] + else: + # Revenue table format: 2025-02-05 Planned £ + week = parts[0] - id_key = f"{week}_planned_ids" if "planned" in side_lower else f"{week}_actual_ids" + # ---------------------------------------------------- + # 2. Detect planned vs actual + # ---------------------------------------------------- + label = col_id.lower() + is_planned = "planned" in label + id_key = f"{week}_planned_ids" if is_planned else f"{week}_actual_ids" raw_ids = row.get(id_key, "") if not raw_ids: