fix(analytics-route): exclude soft-deleted measurements in chunked series fetch

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.
This commit is contained in:
Marc-André Bombeck committed 2026-05-21 12:16:13 +02:00
1 parent 6901b0791d
commit fa36817040
1 file changed
+3
+3
View File
@@ -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: {