Перейти к основному содержимому

Rollup & cleanup jobs

Generated from pattern-library/registry.json — do not edit by hand; change the registry and run bun 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 · Maturity: proven (verified 2026-08-20 @ 1a130d67) · 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)

Tests

  • src/lib/server/jobs/analytics-rollup.pglite.test.ts — Pins the rollup half; the cleanup job shares the registry plumbing (GitHub · GitLab)

Machine-readable record: analytics-rollup-cleanup in pattern-library/registry.json.

← Back to Pattern Library

Думаете, этот паттерн можно сделать лучше? Расскажите как.

Оставить отзыв