From fa36817040b88cfebb161424d8df670f30a09870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 21 May 2026 12:16:13 +0200 Subject: [PATCH] fix(analytics-route): exclude soft-deleted measurements in chunked series fetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three Measurement reads in the analytics route — glucose-by-context, sleep-stage breakdown, and the fetchMeasurementSeriesChunked paged helper that backs the per-type summarize loop and the BP-Zielbereich windowing — were still pulling soft-deleted rows. W-DELETED skipped this file assuming the W-POOL pool / p-limit pass covered it, but that pass only addressed concurrency, not the deletedAt predicate. Adds deletedAt: null to all three findMany clauses so the route shares the same soft-delete contract as every other analytics read path. iOS soft-delete unblocked. --- src/app/api/analytics/route.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/api/analytics/route.ts b/src/app/api/analytics/route.ts index 6db4d3e1b..5283e600f 100644 --- a/src/app/api/analytics/route.ts +++ b/src/app/api/analytics/route.ts @@ -509,6 +509,7 @@ async function buildAnalyticsResponse(user: AuthedUser) { userId: user.id, type: "BLOOD_GLUCOSE", measuredAt: { gte: glucoseSince }, + deletedAt: null, }, orderBy: { measuredAt: "asc" }, select: { value: true, measuredAt: true, glucoseContext: true }, @@ -618,6 +619,7 @@ async function computeSleepStageBreakdown( type: "SLEEP_DURATION", sleepStage: { not: null }, measuredAt: { gte: since }, + deletedAt: null, }, select: { value: true, measuredAt: true, sleepStage: true }, }); @@ -727,6 +729,7 @@ async function fetchMeasurementSeriesChunked( userId, type, ...(options.since ? { measuredAt: { gte: options.since } } : {}), + deletedAt: null, }, orderBy: [{ measuredAt: "asc" }, { id: "asc" }], select: {