fix(labs): stop projecting lab trends from stale or short series

A marker whose newest reading is more than a year old is now reported
as of that reading (projection "stale"), with no exit date and no
already-outside verdict. The projection horizon is capped at the span
the readings cover, so a line is never carried further ahead than the
data reaches back. The detail read keeps the newest 2000 readings
rather than the oldest.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 22:40:43 +02:00
1 parent 5f563623d7
commit e482f76508
16 files changed
+165 -30

No files matched your search

+3 -1
View File
@@ -74,7 +74,9 @@ export const GET = apiHandler(
deletedAt: null,
value: { not: null },
},
orderBy: { takenAt: "asc" },
// Newest first, so a capped read keeps the recent end of the series
// (the staleness check reads the newest reading); the fit sorts.
orderBy: { takenAt: "desc" },
take: LAB_TREND_READ_CAP,
select: { takenAt: true, value: true },
}),