Skip to content

fix(stats): paginate sync aggregates - #50198

Merged
adamdotdevin merged 1 commit into
devfrom
fix-stats-sync
Sep 20, 2026
Merged

adamdotdevin merged 1 commit into
devfrom
fix-stats-sync

Conversation

@adamdotdevin

@adamdotdevin adamdotdevin commented Sep 20, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Production data stopped refreshing after September 19 at 20:17 UTC. The weekly geography query now returns more than R2 SQL's 10,000-row limit, aborting every hourly sync.

Type of change

  • Bug fix

What does this PR do?

Page usage and geography aggregates with a cursor over their unique dimension keys. Apply pagination after aggregation to preserve distinct counts, averages, and geography totals. Keep the row-limit guard for queries without a cursor, and fail the sync if any page fails.

How did you verify your code works?

27 stats-core tests pass, including real SQLite pagination at 0, 9,999, 10,000, 10,001, and 20,005 rows, cursor escaping, and later-page failure handling. Stats core/server typechecks, formatting, and git diff --check pass. A read-only production replay recovered all 10,865 weekly geography rows exactly once; its summed request count matched an independent aggregate query. Repository-wide local typechecking also passed.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@adamdotdevin
adamdotdevin enabled auto-merge (squash) September 20, 2026 16:54
@adamdotdevin
adamdotdevin merged commit 45ad8dc into dev Sep 20, 2026
12 checks passed
@adamdotdevin
adamdotdevin deleted the fix-stats-sync branch September 20, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant