refactor(drain): hoist DRAIN_CUMULATIVE_CUTOFF_HOURS into the helper module

The 36-hour grace window was a module-local constant inside
reminder-worker.ts while the admin route and the CLI both defaulted
to undefined. Lift the constant onto the helper module so the worker,
the admin route, and the CLI all import one source of truth. The
worker continues to pass the constant through to the helper; the
admin route and the CLI keep their existing default-undefined
behaviour (drain everything the operator points at) so a one-shot
pass still collapses every row regardless of recency.
This commit is contained in:
Marc-André Bombeck committed 2026-05-17 17:16:58 +02:00
1 parent 507295ecca
commit debf49303b
5 files changed
+58 -8

No files matched your search

+12 -1
View File
@@ -32,7 +32,18 @@
import "dotenv/config";
import { prisma } from "@/lib/db";
import { drainPerSampleCumulative } from "@/lib/measurements/drain-per-sample-cumulative";
import {
drainPerSampleCumulative,
DRAIN_CUMULATIVE_CUTOFF_HOURS,
} from "@/lib/measurements/drain-per-sample-cumulative";
// v1.4.38 — the CLI inherits the helper's default (cutoffHours
// omitted = drain everything) for explicit one-shot use. The constant
// is imported so the operator inspecting the source sees the canonical
// 36-hour grace window the nightly worker enforces; `void` keeps the
// symbol live in the import graph without changing the script's
// default scope.
void DRAIN_CUMULATIVE_CUTOFF_HOURS;
interface ParsedArgs {
userId?: string;