mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
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.
This commit is contained in:
1 parent
cb825ec67a
commit
84b54d9f11
9 files changed
+280
-1493
No files matched your search
@@ -0,0 +1,22 @@
|
||||
-- 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);
|
||||
@@ -513,12 +513,18 @@ model WithingsConnection {
|
||||
model MoodEntry {
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
date String // YYYY-MM-DD
|
||||
date String // YYYY-MM-DD — anchored to `tz` when not null, else legacy Europe/Berlin
|
||||
mood String // SUPER_GUT, GUT, OKAY, SCHLECHT, LAUSIG
|
||||
score Int // 1-5
|
||||
tags String? // JSON array of tag keys
|
||||
source String @default("MOODLOG") // WEB, TELEGRAM, DAYLIO
|
||||
moodLoggedAt DateTime @map("mood_logged_at")
|
||||
/// v1.4.25 W7b — per-row IANA timezone that the `date` string is
|
||||
/// anchored to. Nullable for backward compatibility: legacy rows
|
||||
/// (`tz IS NULL`) were written under the Europe/Berlin assumption
|
||||
/// and read-paths interpret them as such. New rows always carry the
|
||||
/// user's `displayTimezone` at write time.
|
||||
tz String?
|
||||
syncedAt DateTime @default(now()) @map("synced_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
Reference in new issue
Block a user