fix(medications): never backfill days an edit reopens under auto-take

A start moved earlier, an end moved later or removed, or a medication
made active again reopened past slots, and the auto-take pass filled up
to a week of them as taken. The course window writer and the
re-activation paths now move the auto-take floor to the moment of the
edit.
This commit is contained in:
Marc-André Bombeck committed 2026-10-11 15:07:06 +02:00
1 parent 23e0cc35af
commit 0ff1340ff4
6 files changed
+202 -7

No files matched your search

+7 -1
View File
@@ -32,7 +32,10 @@ import {
toRevisionPayloadEntry,
} from "@/lib/medications/scheduling/schedule-eras";
import type { Prisma } from "@/generated/prisma/client";
import { loadAutoTakeRollingAnchors } from "@/lib/medications/auto-take";
import {
loadAutoTakeRollingAnchors,
moveAutoTakeFloorToNow,
} from "@/lib/medications/auto-take";
import {
computeDisplayDue,
OVERDUE_LOOKBACK_MS,
@@ -1022,6 +1025,9 @@ export const PUT = apiHandler(
where: { medicationId: id, userId: user.id, resumedAt: null },
data: { resumedAt: new Date() },
});
// v1.42.2 — made active again: the auto-take pass starts from
// now, never filling the inactive days as taken.
await moveAutoTakeFloorToNow(tx, id);
}
// v1.40 (#1024) — write the window onto the latest course and