Retention (§6.18)
archive: stale or never run
E-M7-03 production rollout of the §6.18 retention policy. Full granularity for 365d, weekly collapse 365–1825d, monthly > 1825d. Each cron run optionally archives the snapshot to R2 for disaster recovery (acceptance: lekanb@gmail.com's historical snapshots survive a Postgres restore from R2).
Failed query:
SELECT
count(*)::int AS total,
count(*) FILTER (
WHERE calculated_at >= now() - ($1 * interval '1 day')
)::int AS full_count,
count(*) FILTER (
WHERE calculated_at < now() - ($2 * interval '1 day')
AND calculated_at >= now() - ($3 * interval '1 day')
)::int AS weekly_eligible,
count(*) FILTER (
WHERE calculated_at < now() - ($4 * interval '1 day')
)::int AS monthly_eligible,
count(*) FILTER (WHERE is_protected = true)::int AS protected_count,
MIN(calculated_at) AS oldest
FROM score_records
params: 365,365,1825,1825