Background & current state
Computing analytics/leaderboards by scanning raw indexed events is expensive and won't scale to thousands of campaigns/participants. There are no precomputed rollups.
Goal
Maintain materialized rollup tables derived incrementally from indexed events so dashboards and leaderboards read precomputed aggregates in <50ms.
Technical design
- Rollups:
participants_by_day, credits_by_day, claims_by_day, campaign_funnel(registered, credited, claimed), top_participants(campaign_id, address, points).
- Update incrementally as new events are projected (NEW-024) — apply deltas, not full recompute. Support idempotent reprocessing (recompute a day from raw if needed).
- Index rollup tables for the exact dashboard/leaderboard queries.
Edge cases
- Late/out-of-order events → upsert deltas keyed by (campaign, day).
- Reconciliation (NEW-025) recomputes affected rollup buckets.
- Time zones → store UTC; document.
- Ties in leaderboards → deterministic tiebreak (e.g., earliest ledger).
Task breakdown
Acceptance criteria
Testing & verification
- Benchmark before/after; correctness test vs. recompute-from-raw.
Out of scope
Dependencies / related
- Builds on NEW-024/025; feeds NEW-027, NEW-099.
Difficulty: medium · Effort: M · indexer + performance
Background & current state
Computing analytics/leaderboards by scanning raw indexed events is expensive and won't scale to thousands of campaigns/participants. There are no precomputed rollups.
Goal
Maintain materialized rollup tables derived incrementally from indexed events so dashboards and leaderboards read precomputed aggregates in <50ms.
Technical design
participants_by_day,credits_by_day,claims_by_day,campaign_funnel(registered, credited, claimed),top_participants(campaign_id, address, points).Edge cases
Task breakdown
Acceptance criteria
Testing & verification
Out of scope
Dependencies / related
Difficulty: medium · Effort: M · indexer + performance