mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
Lift the mood aggregates the AI status generator already computes — tag frequency + per-tag average, in-target share, and the mood × metric Pearson correlations — into a shared `mood-aggregates.ts` so the prose and the new charts read off one implementation. `mood-status.ts` now consumes the shared helpers instead of its own inline copies. Add a cached `/api/mood/insights` endpoint that returns the pre-computed shapes (summary, heatmap, distribution, weekday, tags, correlations) behind a 60-second server cache and a bounded 365-day read — a cheap read-only path, never a synchronous model call. The bucket invalidates alongside the mood-analytics cache on a mood write. Render the shapes on the mood Insights page: - a calendar heatmap forked from the compliance heatmap, coloured by the same mood-score bands as the line chart, with an adaptive window (30 days until ~90 days of history, then 90, then a full year past 180 days) so the grid is never mostly empty; - a mood distribution bar chart (share of days per level); - average mood by weekday with a best/toughest-day callout; - a tag / trigger breakdown (frequency bars + per-tag average); - mood vs. sleep / activity / pulse correlation cards reusing the existing scatter chart. Add the supporting i18n keys across all six locales.