Rollup & cleanup jobs
Generated from
mcp/patterns.registry.json— do not edit by hand; change the registry and runbun run patterns:build.
Index card — the docs below are the canonical explanation; deep-tier pattern pages additionally carry invariants and emulation notes.
Category: Analytics · Tier: light · Risk: low — background job scoped to analytics tables, idempotent
Two scheduled jobs aggregate yesterday's events into a daily_page_stats table and enforce per-table retention windows (60-180 days) across the analytics tables.
When to use: Use this pair as the pattern for turning raw event tables into a trend-friendly daily rollup while keeping storage bounded.
Docs
Code
src/lib/server/jobs/analytics-rollup.ts(GitHub · GitLab)src/lib/server/jobs/analytics-cleanup.ts(GitHub · GitLab)
Machine-readable record: analytics-rollup-cleanup in mcp/patterns.registry.json.