fix(insights): keep deleted mood entries and readings out of status snapshots

Four per-metric status snapshots read mood context without the tombstone
filter, and the blood-pressure snapshot read measurements the same way, so
a deleted entry kept shaping the text written about it. The breathing
screen and the HRV widget probe had the same gap.

One reader now serves the shared mood context, and a guard derives the
soft-deleting models from the schema and fails on any unfiltered read in
the analysis, insight and model-input directories.
This commit is contained in:
Marc-André Bombeck committed 2026-10-20 09:15:31 +02:00
1 parent fea1d1e0b5
commit 67e2563c63
10 files changed
+254 -33

No files matched your search

+5 -1
View File
@@ -245,7 +245,11 @@ export const GET = apiHandler(async () => {
let hasSdnn = true;
if (!recoveryEnabled) {
const sdnnRow = await prisma.measurement.findFirst({
where: { userId: user.id, type: "HEART_RATE_VARIABILITY" },
where: {
userId: user.id,
type: "HEART_RATE_VARIABILITY",
deletedAt: null,
},
select: { id: true },
});
hasSdnn = sdnnRow !== null;
@@ -48,6 +48,7 @@ export const GET = apiHandler(async () => {
const rows = await prisma.measurement.findMany({
where: {
userId: user.id,
deletedAt: null,
type: { in: ["BREATHING_DISTURBANCES", "BREATHING_DISTURBANCE_EVENT"] },
measuredAt: { gte: since },
},