fix(jobs): register DRAIN_CUMULATIVE_QUEUE in worker boot allQueues

pg-boss v12 requires explicit createQueue before scheduling. The
nightly drain schedule registered without a matching createQueue call,
which silently no-ops the cron — the per-sample Apple Health rows
never collapse into one row per day. The list view still works via
the on-demand groupBy=day branch, but the underlying table stays
bloated forever.

Add the queue to the allQueues array next to ROLLUP_FULL_BACKFILL_QUEUE
so the boot loop creates it before the schedule registration runs.
Extend the existing scheduler test to grep the allQueues block so a
future regression flips red instead of slipping through.
This commit is contained in:
Marc-André Bombeck committed 2026-05-17 15:15:41 +02:00
1 parent 1beeb28a2c
commit 6325c0e286
18 files changed
+3935

No files matched your search

@@ -50,4 +50,15 @@ describe("reminder-worker — drainPerSampleCumulative nightly schedule", () =>
/\[DRAIN_CUMULATIVE_QUEUE,\s*DRAIN_CUMULATIVE_CRON\]/,
);
});
it("registers the drain queue in the allQueues createQueue loop", () => {
// pg-boss v12 requires explicit createQueue before scheduling. The
// allQueues array drives the boot-time `for (const q of allQueues)`
// loop; missing the entry silently no-ops the schedule below.
const allQueuesMatch = source.match(
/const allQueues\s*=\s*\[([\s\S]*?)\];/,
);
expect(allQueuesMatch).not.toBeNull();
expect(allQueuesMatch![1]).toMatch(/\bDRAIN_CUMULATIVE_QUEUE\b/);
});
});
+5
View File
@@ -1525,6 +1525,11 @@ export async function startReminderWorker() {
APPLE_HEALTH_IMPORT_QUEUE,
ROLLUP_RECOMPUTE_QUEUE,
ROLLUP_FULL_BACKFILL_QUEUE,
// v1.4.37 W7c — explicit createQueue is required before the
// nightly schedule below registers (pg-boss v12 contract). Without
// this entry the drain schedule silently no-ops and the
// per-sample APPLE_HEALTH rows never collapse.
DRAIN_CUMULATIVE_QUEUE,
];
for (const q of allQueues) {