chore(release): v1.4.39 — mood, medication-compliance, and cumulative-sum rollup tiers

Squashed merge of the v1.4.39 wave work from develop. The release
extends the v1.4.38 fast-path posture to two more endpoints that
still walked the source table on every cold mount and folds a
cumulative `sum_value` column into the existing rollup tier so step /
flight / distance / daylight / active-energy sparklines no longer
re-derive their daily totals in Node.

Raw measurements / mood_entries / medication_intake_events tables are
byte-unchanged. Three new tiers (mood_entry_rollups,
medication_compliance_rollups, measurement_rollups.sum_value) are
derived caches that self-heal via boot-time backfill on first reach.

Migrations 0070, 0071, 0072 are additive only. The sum_value column
add is catalog-only DDL on PostgreSQL 11+ — no table rewrite, writes
resume in milliseconds. No environment-variable change. No API
contract break. No iOS contract change.

Expected wins (live perf-verify rides the post-deploy window):
- /api/mood/analytics cold 12.7 s -> ~200 ms
- /api/medications/intake?scope=compliance cold 3.2 s -> ~200 ms
- /api/dashboard/summary cumulative sparkline ~500 ms -> ~300 ms
- /api/analytics live-fallback row cap 347 k -> ~5 k (425 d cap
  preserves the year-ago baseline tile)

Tests 4 524 -> 4 640 (+116). Typecheck clean. Lint clean.

See CHANGELOG.md for the full v1.4.39 entry.
This commit is contained in:
Marc-André Bombeck committed 2026-05-21 07:39:10 +02:00
1 parent 8a8150d2bf
commit d84922cdc3
59 files changed
+8272 -29

No files matched your search

@@ -8,6 +8,7 @@ import { moodLogWebhookPayloadSchema } from "@/lib/validations/moodlog";
import { readMoodLogSecret } from "@/lib/moodlog-secret";
import { apiHandler } from "@/lib/api-handler";
import { annotate, getEvent } from "@/lib/logging/context";
import { recomputeMoodBucketsForEntry } from "@/lib/mood/rollups";
export const dynamic = "force-dynamic";
@@ -124,6 +125,19 @@ export const POST = apiHandler(async (request: NextRequest) => {
},
});
}
// v1.4.39 W-MOOD — refresh the persisted rollup for the entry's
// bucket. Inline best-effort: a failure here must not block the
// webhook 200 response (the rollup is a cache tier, the source-of-
// truth is the mood_entries write that already committed).
try {
await recomputeMoodBucketsForEntry(user.id, moodLoggedAt);
} catch (rollupErr) {
getEvent()?.addWarning(
"Mood rollup recompute failed: " +
(rollupErr instanceof Error ? rollupErr.message : String(rollupErr)),
);
}
} catch (err) {
getEvent()?.addWarning("DB operation failed: " + err);
}