From 4e1f2d469452110166c4fb88cd4f7bb85d35cf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 18 May 2026 12:58:45 +0200 Subject: [PATCH] refactor(dashboard-summary): flatten nested ternary per CLAUDE.md QA Simplifier (v1.4.39): the cumulative-vs-spot sparkline branch in the `sparkByType` loop was a nested ternary (`useSum ? (row.sum_value !== null ? sum : mean * count) : mean`). CLAUDE.md bans nested ternaries; the fix hoists the cumulative branch into a named local so the outer ternary is single-level. --- src/app/api/dashboard/summary/route.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/api/dashboard/summary/route.ts b/src/app/api/dashboard/summary/route.ts index 88a352c95..458330162 100644 --- a/src/app/api/dashboard/summary/route.ts +++ b/src/app/api/dashboard/summary/route.ts @@ -449,11 +449,17 @@ async function buildDashboardSummary( const sparkByType = new Map(); for (const row of sparkBuckets) { const list = sparkByType.get(row.type) ?? []; - const useSum = CUMULATIVE_HK_TYPES.has(row.type); - const point = useSum - ? (row.sum_value !== null - ? Number(row.sum_value) - : Number(row.mean) * Number(row.count)) + // QA Simplifier (v1.4.39): flatten the cumulative-vs-spot ternary + // into a named branch per the CLAUDE.md "no nested ternaries" + // rule. Cumulative tiles paint the daily SUM; spot tiles keep the + // daily MEAN. The legacy NULL fallback covers pre-v1.4.39 rollup + // rows the boot-backfill hasn't refreshed yet. + const cumulativePoint = + row.sum_value !== null + ? Number(row.sum_value) + : Number(row.mean) * Number(row.count); + const point = CUMULATIVE_HK_TYPES.has(row.type) + ? cumulativePoint : Number(row.mean); list.push(point); sparkByType.set(row.type, list);