Skip to content

Fix pagination: sync all 102 followed users instead of just 30#33

Merged
justinabrahms merged 1 commit into
mainfrom
work/gentle-eagle
Jan 22, 2026
Merged

Fix pagination: sync all 102 followed users instead of just 30#33
justinabrahms merged 1 commit into
mainfrom
work/gentle-eagle

Conversation

@justinabrahms
Copy link
Copy Markdown
Owner

Summary

Fixes the issue where gitstreams only syncs ~30 followed users instead of all 102.

The root cause was that GitHub's API returns 30 results per page by default, but we were only fetching the first page of results. This meant users beyond position 30 (like 'expede') were missing from the feed.

Changes

  • Added getPaginated() helper function that fetches all pages using GitHub's pagination (100 items per page, which is the maximum)
  • Updated 8 GitHub API methods to use pagination:
    • GetFollowedUsers
    • GetFollowedUsersByUsername
    • GetStarredRepos
    • GetStarredReposByUsername
    • GetOwnedRepos
    • GetOwnedReposByUsername
    • GetRecentEvents
    • GetReceivedEvents
  • Added comprehensive pagination tests to verify correct behavior with multiple pages

Testing

  • All existing tests pass
  • New pagination tests verify:
    • Multi-page fetching (202 users across 3 pages)
    • Correct handling of exactly 100 items (single full page)
    • Proper termination when fewer than per_page items are returned

Impact

Users will now see activity from all their followed users, not just the first 30. This ensures a complete and accurate feed.

Fix issue where only 30 followed users were synced instead of all 102.
GitHub API returns 30 results per page by default, but we were only
fetching the first page.

Changes:
- Add getPaginated() helper that fetches all pages (100 items/page)
- Update all list methods to use pagination:
  * GetFollowedUsers
  * GetFollowedUsersByUsername
  * GetStarredRepos
  * GetStarredReposByUsername
  * GetOwnedRepos
  * GetOwnedReposByUsername
  * GetRecentEvents
  * GetReceivedEvents
- Add comprehensive pagination tests

This ensures users like 'expede' who were beyond the first 30 results
will now appear in the feed.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@justinabrahms justinabrahms added the multiclaude PR created by multiclaude worker label Jan 22, 2026
@justinabrahms justinabrahms merged commit 0a33c1e into main Jan 22, 2026
2 checks passed
justinabrahms added a commit that referenced this pull request Jan 22, 2026
Investigation reveals three issues causing slowdown:

1. Cache invalidation (one-time): URL changes invalidated ETags
2. Extra API calls for exactly 100 items: Main issue causing 23-50%
   slowdown for affected users
3. No multi-page caching: Minor cumulative impact

The main culprit is issue #2: current logic makes an extra API call
when result sets have exactly 100 items because it can't distinguish
between 'exactly 100 total' and '100 with more pages'.

Solution: Use GitHub's Link header to detect pagination instead of
guessing based on result count.

Files:
- PAGINATION_ANALYSIS.md: Complete technical analysis with impact tables
- PAGINATION_FIX_POC.md: Implementation guide showing how to fix issue #2

For users following 100 people where 30% have exactly 100 items:
- Current: ~391 API calls
- After fix: ~301 API calls (23% reduction)
justinabrahms added a commit that referenced this pull request Jan 22, 2026
Investigation reveals three issues causing slowdown:

1. Cache invalidation (one-time): URL changes invalidated ETags
2. Extra API calls for exactly 100 items: Main issue causing 23-50%
   slowdown for affected users
3. No multi-page caching: Minor cumulative impact

The main culprit is issue #2: current logic makes an extra API call
when result sets have exactly 100 items because it can't distinguish
between 'exactly 100 total' and '100 with more pages'.

Solution: Use GitHub's Link header to detect pagination instead of
guessing based on result count.

Files:
- PAGINATION_ANALYSIS.md: Complete technical analysis with impact tables
- PAGINATION_FIX_POC.md: Implementation guide showing how to fix issue #2

For users following 100 people where 30% have exactly 100 items:
- Current: ~391 API calls
- After fix: ~301 API calls (23% reduction)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

multiclaude PR created by multiclaude worker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant