Merge branch 'feat/medication-record-only' into release/v1.39.1

This commit is contained in:
Marc-André Bombeck committed 2026-09-25 09:37:27 +02:00
commit e03cf7c2c8
81 files changed
+2283 -274

No files matched your search

@@ -92,7 +92,7 @@ describe("POST /api/admin/notifications/reminder-check", () => {
expect(res.status).toBe(200);
const json = (await res.json()) as { data: { scoped: boolean } };
expect(json.data.scoped).toBe(false);
expect(whereOfLastFindMany()).toEqual({ active: true });
expect(whereOfLastFindMany()).toEqual({ active: true, trackIntake: true });
});
it("narrows the sweep to the named account", async () => {
@@ -102,6 +102,7 @@ describe("POST /api/admin/notifications/reminder-check", () => {
expect(json.data.scoped).toBe(true);
expect(whereOfLastFindMany()).toEqual({
active: true,
trackIntake: true,
userId: "cku0mock0account0id",
});
});
@@ -8,6 +8,7 @@ import { adminReminderCheckSchema } from "@/lib/validations/notifications";
import { parseScheduleRecurrence } from "@/lib/medication-schedule";
import { dispatchLocalisedNotification } from "@/lib/notifications/dispatch-localised";
import { getUserTodayBounds, getDayOfWeekInTz } from "@/lib/tz/local-day";
import { TRACKED_INTAKE_WHERE } from "@/lib/medications/intake-tracking";
export const dynamic = "force-dynamic";
@@ -99,6 +100,9 @@ export const POST = apiHandler(async (request: NextRequest) => {
const medications = await prisma.medication.findMany({
where: {
active: true,
// v1.39.1 (#1033) — the manual check reminds exactly what the worker
// reminds: never a medication with intake tracking off.
...TRACKED_INTAKE_WHERE,
// Absent selector ⇒ no `userId` key ⇒ the instance-wide sweep.
...(scopedUserId ? { userId: scopedUserId } : {}),
},