mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(nutrients): evict the dashboard snapshot on a landed batch row
POST /api/nutrients/batch performed zero cache invalidation, so an Apple-Health-synced water/nutrient total kept the dashboard's tile serving the pre-sync figure until the analytics fresh TTL lapsed (~3 min) — the manual water POST already hard-evicts on its own write. Calls invalidateUserDashboardSnapshot(user.id) once at least one row inserted or updated, mirroring the manual route's own posture so a synced total reflects on the very next dashboard read.
This commit is contained in:
1 parent
56a32c528e
commit
1d559d7ed0
2 files changed
+46
No files matched your search
@@ -40,6 +40,7 @@ import {
|
||||
import { withIdempotency } from "@/lib/idempotency";
|
||||
import { checkRateLimit } from "@/lib/rate-limit";
|
||||
import { requireModuleEnabled } from "@/lib/modules/gate";
|
||||
import { invalidateUserDashboardSnapshot } from "@/lib/cache/invalidate";
|
||||
import { NUTRIENT_CATALOG } from "@/lib/nutrients/catalog";
|
||||
import {
|
||||
MAX_NUTRIENT_ENTRIES_PER_BATCH,
|
||||
@@ -324,6 +325,13 @@ async function postBatch(request: NextRequest): Promise<Response> {
|
||||
skipped: skipped.length,
|
||||
},
|
||||
});
|
||||
// v1.30.3 (QA F9) — a landed row changes the dashboard's water/nutrient
|
||||
// tile; without this the snapshot kept serving the pre-sync figure
|
||||
// until the analytics fresh TTL lapsed (~3 min). Mirrors the manual
|
||||
// water POST's own hard-evict (`nutrients/water/route.ts`) so an
|
||||
// Apple-Health-synced total reflects on the very next dashboard read,
|
||||
// same as a manually logged one.
|
||||
invalidateUserDashboardSnapshot(user.id);
|
||||
}
|
||||
|
||||
annotate({
|
||||
|
||||
Reference in new issue
Block a user