Skip to content

Fix analytics page crashes for large star counts#7

Open
natea wants to merge 3 commits intoadambkovacs:mainfrom
natea:fix/analytics-page-crashes
Open

Fix analytics page crashes for large star counts#7
natea wants to merge 3 commits intoadambkovacs:mainfrom
natea:fix/analytics-page-crashes

Conversation

@natea
Copy link
Copy Markdown

@natea natea commented Apr 15, 2026

Summary

  • listRepoSnapshotsByFullNames: Replace N individual indexed queries with single repoSnapshots .collect() + in-memory grouping — was exceeding Convex 4096 read limit with 2000+ repos
  • listPortfolioEvents: Cap results with .take(8192) to stay within Convex max array return size (was returning 9560 events)
  • DriftChart: Replace Math.max(...spread) with iterative loop to avoid stack overflow on large datasets

Fixes #6

Note: This PR depends on #4 (import-time read limit fixes). Both address scaling issues for accounts with many starred repos.

Test plan

  • Analytics page loads without errors for accounts with 2000+ starred repos
  • Drift chart renders without stack overflow
  • Dashboard and search pages still load correctly
  • bun run typecheck and bun run lint pass

🤖 Generated with Claude Code

natea and others added 3 commits April 15, 2026 13:57
Remove the case-insensitive fallback that called .collect() on the
entire repoCatalog table. During first import, every repo triggered
this fallback since no existing match was found, causing O(n²) document
reads that exceeded Convex's 32k limit around ~600 repos.

The indexed lookup via by_fullName is sufficient — GitHub returns
consistently-cased fullName values.

Fixes adambkovacs#3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace N+1 db.get() join patterns with efficient alternatives:
- listUserRepoStates: denormalize repoFullName onto userRepoStates
  to eliminate joins entirely (with fallback for existing rows)
- listPortfolioEvents: single repoCatalog .collect() + map lookup
  instead of per-event db.get()
- listUserNotes: same .collect() approach with early return for empty

These queries previously did Promise.all(ids.map(id => db.get(id)))
which counted as N separate read operations, exceeding Convex's 4096
read limit for accounts with 500+ starred repos.

Fixes adambkovacs#5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- listRepoSnapshotsByFullNames: replace N indexed queries with single
  .collect() + in-memory grouping (was exceeding 4096 read limit)
- listPortfolioEvents: cap at .take(8192) to stay within Convex max
  array return size (was returning 9560 events)
- DriftChart: replace Math.max(...spread) with iterative loop to avoid
  stack overflow with large datasets

Fixes adambkovacs#6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

@natea is attempting to deploy a commit to the AI Enablement Academy's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Analytics page crashes: stack overflow in drift chart and snapshot query read limits

1 participant