Files
HealthLog/prisma/migrations/0148_v1168_insight_snapshot_hash/migration.sql
T
Marc-André Bombeck 23f7c74c04 perf(insights): regenerate texts only when the underlying data changed
A sha256 fingerprint of the compacted feature snapshot is stored beside
every generated text; nightly, forced and ingest-triggered regeneration
all skip the model call when the fingerprint matches and refresh the
timestamp instead. Warms cover only the user's resolved locale and the
blanket per-status eviction after a comprehensive generation is gone —
a lazily-read second locale regenerates on its own miss path. The
ingest debounce widens from thirty minutes to six hours and no longer
deletes cache rows, the visit-triggered warm re-checks freshness at job
start, backs off for an hour after a failure and is capped at two
forced runs per user per day, and its dedup window now outlives the
client poll horizon. An active day drops from hundreds of model calls
to a handful tied to actual data change.
2026-06-11 21:17:05 +02:00

16 lines
807 B
SQL

-- v1.16.8 — content-hash gate for insight regeneration.
--
-- `insights_snapshot_hash` stores the SHA-256 fingerprint of the
-- compacted feature snapshot the cached comprehensive insight was
-- generated from. Nightly, forced, and lazy regenerations compare the
-- fresh snapshot's hash against it and skip the provider call
-- (refreshing only `insights_cached_at`) when nothing the prompt sees
-- has changed.
--
-- `insights_warm_failed_at` records the last failed/timed-out forced
-- warm of the comprehensive insight, so the forced path can back off
-- for an hour instead of re-attempting a broken provider chain on
-- every page-open. Additive + non-destructive.
ALTER TABLE "users" ADD COLUMN "insights_snapshot_hash" TEXT;
ALTER TABLE "users" ADD COLUMN "insights_warm_failed_at" TIMESTAMP(3);