Skip to content

Analytics: time-range/granularity controls + worker-backed incremental aggregation - #556

Merged
james2177 merged 3 commits into
stellar-vortex-protocol:mainfrom
NuMziE26:drips/462-463
Sep 30, 2026
Merged

james2177 merged 3 commits into
stellar-vortex-protocol:mainfrom
NuMziE26:drips/462-463

Conversation

@NuMziE26

Copy link
Copy Markdown
Contributor

Summary

Analytics: time-range/granularity controls + worker-backed incremental aggregation

What was solved

#462 — [High] Add time-range and granularity controls to Analytics with correct UTC bucketing

Add user-selectable time ranges (24h/7d/30d/90d/custom) and granularity (hour/day/week) to the Analytics page, refactoring computeAnalytics into a pure, time-injected function that buckets by UTC via explicit helpers, fills gaps with zeros, counts and surfaces ignored invalid timestamps, syncs selection to the URL, shows a data-completeness notice when the capped feed doesn't cover the range, and documents the timezone policy with a local-time axis-label toggle.

Addressed:

  • Changed: src/lib/time.ts, src/lib/analytics.ts, src/lib/time.ts
  • Make computeAnalytics(intents, {from, to, granularity, now}) pure with injected time (no Date.now() inside)
  • Bucket by UTC using explicit helpers (startOfUtcHour/Day/Week) in src/lib/time.ts, with correct ISO-week handling across year boundaries
  • Fill empty buckets with zeros and reject/ignore invalid timestamps, surfacing counts of ignored rows in the UI

#463 — [High] Move heavy analytics computation off the main thread with a Web Worker and memoized incremental updates

Move the heavy computeAnalytics aggregation off the main thread by introducing a shared incremental aggregator core, a Web Worker wrapper exposing init/apply/snapshot over a typed message protocol, and wiring the analytics page to render from worker snapshots with deferred/transition semantics, while falling back to synchronous computation when Worker is unavailable.

Addressed:

  • Changed: src/lib/analytics.ts, src/lib/analytics/worker.ts, src/app/analytics/AnalyticsPageClient.tsx
  • Create a shared incremental aggregator class with add/update/remove (insert, status change, eviction) that both the sync API and the worker wrap.
  • Add a new Web Worker module exposing init(intents, options), apply(delta) and snapshot() over a typed message protocol.
  • Refactor src/lib/analytics.ts so computeAnalytics delegates to the same core aggregator, preserving the existing public API and output shape.

Changes

  • src/lib/time.ts (modify)
  • src/lib/analytics.ts (modify)
  • src/lib/analytics/worker.ts (create)
  • src/app/analytics/AnalyticsPageClient.tsx (modify)

Approach

  1. [High] Add time-range and granularity controls to Analytics with correct UTC bucketing #462 — [High] Add time-range and granularity controls to Analytics with correct UTC bucketing (Changed: src/lib/time.ts, src/lib/analytics.ts, src/lib/time.ts)
  2. [High] Move heavy analytics computation off the main thread with a Web Worker and memoized incremental updates #463 — [High] Move heavy analytics computation off the main thread with a Web Worker and memoized incremental updates (Changed: src/lib/analytics.ts, src/lib/analytics/worker.ts, src/app/analytics/AnalyticsPageClient.tsx)

Issues

Closes #462
Closes #463

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@NuMziE26 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

# Conflicts:
#	src/app/analytics/AnalyticsPageClient.tsx
#	src/lib/analytics.ts
#	src/lib/time.ts
@james2177
james2177 merged commit b1720bd into stellar-vortex-protocol:main Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants