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.
This commit is contained in:
Marc-André Bombeck committed 2026-05-18 12:58:45 +02:00
1 parent 12486e257c
commit 4e1f2d4694
1 file changed
+11 -5
+11 -5
View File
@@ -449,11 +449,17 @@ async function buildDashboardSummary(
const sparkByType = new Map<MeasurementType, number[]>();
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);