mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
Both ingest paths wrote into `measurements` without firing the rollup write hook, leaving the dashboard chart's `source=rollup` fast-path blind to the imported days. The mood / medication-compliance rollup tiers already had post-batch hooks on these routes; the measurement tier had been the gap. - `/api/import`: tracks every touched `(type, measuredAt)` written during the batch, collapses to distinct `(type, day)` via `collapseToTypeDayKeys`, and folds once at the end. A 10 000-row CSV restore now pays at most ~N (type, day) recomputes rather than 10 000 per-row hooks. - Admin backup restore: the transaction wipes the user's `measurement_rollups` partition alongside the existing `mood_entry_rollups` wipe, and the post-transaction step kicks a `recomputeUserRollups(ownerId)` so the restored dataset paints fresh tiles instead of carrying the previous owner's daily means forward. - Best-effort posture preserved in both paths: a populator hiccup surfaces via `annotate` but never undoes the restore / import. Test coverage extends the existing `/api/import` route suite with a regression that pins the per-`(type, day)` collapse and a duplicate- write case (`P2002`) that proves the hook is skipped when nothing was actually written.