mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
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:
1 parent
12486e257c
commit
4e1f2d4694
1 file changed
+11
-5
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user