Files
HealthLog/prisma/migrations/0044_mood_entry_tz_column/migration.sql
T
Marc-André Bombeck 84b54d9f11 refactor(insights): mother page hosts overview only; metric depth moves to sub-pages
After W4a scaffolded the routed sub-pages and lifted the sticky tab
strip into src/app/insights/layout.tsx, the mother page becomes the
overview-only surface it always wanted to be: Hero + DailyBriefing +
CorrelationRow + TrendsRow + InsightAdvisorCard + CoachDrawer.

What's gone from the page (now lives on the matching sub-page):
  - Six per-section <HealthChart> / <MoodChart> mounts (bp/weight/
    pulse/mood/meds/bmi) with their target-zone + value-band wiring.
  - Per-metric status-card queries (blood-pressure-status,
    weight-status, pulse-status, bmi-status, mood-status,
    medication-compliance-status).
  - All the per-section <InsightStatusCard> + scatter-correlation
    cards (BP × continuity, weight × BP, mood × BP, mood × weight).
  - The bulky helper functions (getBloodPressureSectionStatus,
    getWeightSectionStatus, …, classifyRangeValue) and their imports
    (getBpTargets, buildWeightBandsFromHeight, pulse-targets, etc.).
  - The inline <InsightsSectionNav> mount — superseded by the strip
    that <InsightsLayoutShell> now mounts.

What stays here:
  - HeroStrip (greeting, weekly-report banner, Health Score panel).
  - DailyBriefing (the AI morning paragraph).
  - CorrelationRow (cross-metric hypotheses).
  - TrendsRow (BP / weight / mood mini-charts above each annotation).
  - InsightAdvisorCard (the rich recommendations grid).
  - CoachDrawer — mother-page-only, per Marc's directive.

The two insights-polish guard tests are re-pointed at the new homes
of their assertions: the tab-strip refresh affordance now lives on
the layout shell (src/components/insights/insights-layout-shell.tsx),
and the comparisonBaseline plumbing migrated into the shared
useInsightsLayoutPrefs() hook.

trends-row.test.tsx wraps every render in a QueryClientProvider —
the v1.4.25 W7 timezone change added a useAuth() call inside
<TrendsRow> for chart-side userTimezone plumbing, which needs a
TanStack-Query client at mount time.
2026-05-14 13:07:33 +02:00

23 lines
1.0 KiB
SQL

-- v1.4.25 W7b — MoodEntry.tz column (proposal §7 Decision A).
--
-- HealthLog historically wrote `MoodEntry.date` (YYYY-MM-DD) under
-- the implicit Europe/Berlin assumption. Per-user timezone (Option B,
-- feature `feature-user-timezone.md`) makes that assumption wrong for
-- non-Berlin users — a 23:50 NZST reading would bucket into the
-- Berlin day, one day earlier than the user's own "today".
--
-- The fix is per-row tz attribution:
--
-- - New rows: writer captures `User.timezone` at write time, stores
-- it on the row, and computes `date` using that zone.
-- - Legacy rows: `tz IS NULL` is interpreted as "Europe/Berlin"
-- read-side. The historical bucketing stays consistent with the
-- numbers users have already seen.
--
-- Forward-only, additive, idempotent. No backfill is required because
-- the read-path treats `tz IS NULL` as Europe/Berlin (the value those
-- rows would carry if backfilled). Rollback is a manual DROP COLUMN.
ALTER TABLE "mood_entries"
ADD COLUMN IF NOT EXISTS "tz" VARCHAR(64);