Skip to content

fix(github): paginate owned repos beyond the first 100#46

Open
ChristianUtria wants to merge 1 commit into
Younesfdj:masterfrom
ChristianUtria:fix/paginate-repos-beyond-100
Open

fix(github): paginate owned repos beyond the first 100#46
ChristianUtria wants to merge 1 commit into
Younesfdj:masterfrom
ChristianUtria:fix/paginate-repos-beyond-100

Conversation

@ChristianUtria

Copy link
Copy Markdown

Problem

repositories() in the profile query caps at 100 (GraphQL's page limit,
orderBy: STARGAZERS DESC). Any account with more than 100 owned,
non-fork repos has its languages, total stars, and active-years signals
computed from only those top-100-by-stars repos — the rest are silently
ignored.

Example

@sindresorhus has ~1,100 owned repos. Before this fix, his card showed
only 7 languages despite that repo count — because his most-starred repos
happen to be mostly JS/TS, and everything else (which may use other
languages) falls outside the top 100.

Fix

Follows the first repo page up to 2 extra pages (300 repos total) via
cursor pagination, using the same best-effort pattern already used for
fetchLifetime — a failed extra page degrades gracefully (fewer repos
counted) instead of failing the whole scout. Accounts under 100 repos
(the common case) do zero extra requests.

Why cap at 3 pages (300 repos)?

Repo pages are fetched sequentially (each needs the previous page's cursor),
so they can't run in parallel like the lifetime-contribution batches do.
Given the existing 8s request timeout (Vercel's ~10s serverless cap), 3
pages keeps the worst case comfortably inside that budget while covering
the overwhelming majority of profiles. Accounts under 100 repos pay zero
extra requests. This is a tunable constant (REPO_MAX_PAGES), not a hard
architectural limit — easy to revisit if needed.

Verified

  • npx vitest run — 109/109 passing (2 new tests covering the pagination
    follow-through and graceful degradation on failure).

  • npx tsc --noEmit — clean.

  • Compared gitfut.com/sindresorhus (prod, unpatched) vs
    localhost:3000/sindresorhus (this branch) side by side:

    Stat Before (prod) After (this branch)
    Languages 7 (74) 10 (86)
    Stars earned 924k (99) 1010k (99)

GitHub's repositories field caps at 100 per page. Accounts with more
owned repos (e.g. prolific maintainers with 500-1000+ repos) had their
languages, total stars, and active-years signals computed only from
their top 100 most-starred repos, silently undercounting devs whose
less-starred repos use different languages or predate their popular ones.

Follows up to 2 extra pages (300 repos total) via cursor pagination,
mirroring the existing best-effort batching used for lifetime
contributions - a failed extra page degrades gracefully instead of
failing the whole scout.
@valvalcaseres-cmd

Copy link
Copy Markdown

A friend of mine has over 110 repositories and his information was incomplete; I think expanding the mapping to 300 repositories is a great move.

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.

2 participants