fix: use REST API for user search to fix incorrect sort order #113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #112
Summary
The GraphQL user search uses
sort:followers-descin the query string, but GitHub does not support thesort:followersqualifier for user search. This causes non-deterministic results and missing users in the rankings.Changes
Replaces the single GraphQL search query with a two-step approach:
GET /search/users?sort=followers&order=descfor collecting user logins — the REST API officially supportssort=followersand returns correctly sorted results with no duplicatesuser(login:)batch queries (10 users/batch) for fetching detailed data (contributions, organizations, follower counts)Other changes
MinFollowersfield added toUserSearchQueryandQueryPreset— the worldwide preset usesminFollowers: 1000to narrow the search scope. Without this filter, the REST API search may hit GitHub's time limit and return partial results (the response'sincomplete_resultsfield would betrue), since worldwide has 160M+ users.minFollowers()fix — computes the actual minimum across all users instead of using the last user's follower countclaudeaccount — the Anthropic Claude Code co-author account causes GitHub GraphQL to return 504 oncontributionsCollectiondue to its massive co-authored commit volumeTesting
Verified with production settings (
consider=1000,amount=256):Files changed
github/github.goSearchUsers()to use REST + GraphQL two-step approachpresets.gominFollowersfield toQueryPreset; setminFollowers: 1000for worldwidetop/top.goMinFollowerstoOptionsstruct; pass through toUserSearchQuerymain.gopreset.minFollowersand pass totop.Options