mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
The route's central analytics aggregator runs eight `FROM measurements` clauses (window_stats CTE + main aggregate + DISTINCT ON latest + firstAt probe, mirrored across the rollup-fresh and cold-fallback branches) plus one `findMany` for the BP raw rows. None filtered on `deleted_at`, so the Coach/Insights snapshot would see tombstoned readings in every windowed avg, slope, anomaly count, and latest attribution. Add `AND m."deleted_at" IS NULL` to the eight raw SQL filters and `deletedAt: null` to `fetchBpRawRows`. The `measurement_rollups` findMany branch already rides the writer-side filter.