mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
Audit Critical Finding #2 (round-v1439-arch-qa-infra-db). The 90-day `prisma.moodEntry.findMany` block fed two downstream consumers: `dailyMoodEntries` for mood × metric correlations, and `moodSummary` for the dashboard mood block. Both read at a per-day resolution. Swap to `readMoodDayRollups(userId, ninetyDaysAgo)` so the route reads one row per calendar day instead of one per entry. Coverage-fallback runs a bounded 90-day live walk + fires `ensureUserMoodRollupsFresh` so the next request lands on the rollup tier (same posture as /api/mood/analytics post-v1.4.39). `moodSummary` now feeds per-day mean DataPoints into `summarize()` on both branches, matching the rollup-tier convention shipped in v1.4.39 (QA UX-H1). Two parity tests added to `__tests__/route.test.ts`: rollup fast path skips the raw findMany, and the coverage-fallback runs the live walk exactly once when rollups are empty.