Files
HealthLog/src/components
Marc-André Bombeck 1dd1a9a7a5 fix(mood-chart): align queryKey to the shared mood-analytics factory entry
Pre-fix the dashboard mounted two separate consumers against the same
`/api/mood/analytics` endpoint: `app/page.tsx:291` keyed on
`queryKeys.moodAnalytics()` (`["mood-analytics"]`) and the chart at
`mood-chart.tsx:316` keyed on a bare `["mood-chart-data"]` literal.
TanStack treats different keys as separate cache slots, so a cold
dashboard mount fired two requests against the same endpoint — wasting
one HTTP round trip, one pg pool slot, and ~22 KB of payload per cold
mount (empirical-trace #3). Re-key the chart to `queryKeys.moodAnalytics()`
so TanStack dedups the request; align the chart's `staleTime` to the
dashboard's 60 s window so a route swing back to the dashboard within
a minute stays a free cache hit.

The chart's own subscription becomes the cache writer for any insights
/ mood sub-page that mounts it without the dashboard parent having
fetched first. No payload-shape change — the chart already typed its
response as `MoodAnalyticsData` which matches the dashboard's
`{ entries, summary }` shape byte-for-byte.
2026-05-21 11:45:25 +02:00
..
2026-05-17 19:07:03 +02:00
2026-05-14 23:49:32 +02:00
2026-05-15 22:59:10 +02:00
2026-05-17 19:07:03 +02:00
2026-05-15 22:59:10 +02:00
2026-05-17 19:07:03 +02:00
2026-05-17 23:46:09 +02:00
2026-05-17 19:07:03 +02:00
2026-05-15 22:59:10 +02:00