Turns the distinct retention values present into the buckets a purge query needs.
Bucketing rather than per-row date math is what keeps this a small number of indexable range
queries instead of a scan: retention is stamped from the action, so the distinct set is roughly
"one per configured action", not one per log row. Pure and exported so the arithmetic is testable
without a clock or a database.
Parameters
retentionDays: readonlynumber[]
now: Date
the reference instant, passed in rather than read, so a test can pin it.
Turns the distinct retention values present into the buckets a purge query needs.
Bucketing rather than per-row date math is what keeps this a small number of indexable range queries instead of a scan: retention is stamped from the action, so the distinct set is roughly "one per configured action", not one per log row. Pure and exported so the arithmetic is testable without a clock or a database.