This is the code behind committers.top, which ranks the most active GitHub users in each location. It's also a CLI tool that queries the GitHub GraphQL API for users and ranks them by their contributions, with presets for many countries and regions.
GitHub Token
Requests to the GitHub API need an access token, which can be created here. It doesn't need any scopes, since everything the tool reads is public. Pass it with --token, or set GITHUB_TOKEN instead to keep it out of your shell history.
Example usage (dev environment):
go run . \
--token paste-your-token-here \
--preset germany \
--amount 500 \
--consider 1000 \
--output csv \
--file ./output.csv
The plain and csv outputs rank by all contributions, so they leave out users above the All tab's yearly limits (see the FAQ).
Issues and pull requests are welcome: against master for the code, or against the gh-pages branch for the website. Only website changes need gh-pages, which also holds the generated pages with people's names and contribution counts.
Please run go fmt and go vet before sending a PR; CI checks the formatting and runs go vet, go build and go test.
A preset in presets.go is a list of location: search terms: users whose location matches any include term are counted, unless it also matches an exclude term. Terms match whole words in the free-text location, ignoring case (wien doesn't match "Wiener Neustadt"), but accented letters aren't treated as plain ones (pölten doesn't match "Polten").
When adding or changing a preset:
-
Fork with "Copy the
masterbranch only". Thegh-pagesbranch holds the generated pages, including people's names and contribution counts, and isn't needed. -
Choose places by a rule you can state, such as the N largest cities on Wikipedia's list for the country plus any state capitals, and give the rule in the PR. Include the country's name in its own languages and scripts, as the Mongolia (
монгол) and Iraq (العراق) presets do. -
Check what each term matches before adding it, for example with the GitHub CLI:
gh api graphql -f query='query { search(type: USER, query: "type:user location:vizcaya", first: 20) { userCount nodes { ... on User { location } } } }'Drop terms that match nobody. For a name shared with another place, use a more specific term or an
exclude:vizcayaalso matched Nueva Vizcaya in the Philippines, so the Basque Country preset excludesnueva+vizcaya, and Mongolia excludesinner+mongolia. -
Join multi-word names with
+to require all their words, in any order:baden+bei+wienmatches only that town, whilebadenalone matches over a thousand users, mostly in Germany and Switzerland. Add the spellings people use without accents, such aspölten,poeltenandpolten. -
Run the preset locally with a token (see above):
go run . --token paste-your-token-here --preset <name> --output yamlQuote names with spaces, like
--preset "basque country";--list-presetslists them all. In the PR, give thetotal_user_countandmin_followers_requiredit prints, next to the current figures on the location's page.
Since locations are free text, a profile that names several places shows up in all of them, unless it matches more than four presets (see the FAQ); a preset change can't fix that.
This could be due to a number of things.
-
GitHub's API doesn't allow sorting by contributions, so each location first takes its 1,000 most-followed users and then ranks those by contributions. This means you need a minimum number of followers to be on this list, and each page shows that minimum. Each tab then lists only the top 256.
-
You live in a city which is not included in the query. Unfortunately the query is free-text and not strictly geographical. Rural areas may be excluded from the list, but you can often remedy this by adding the country name to your location in GitHub.
-
You have mostly private contributions. These only count on the All tab of each location's page. This arrangement is done to favor open source contributions over private contributions.
-
Your activity is above the yearly limits:
- Commits: 7,500 commits (~20/day)
- Contributions: 10,000 public contributions (~27/day)
- All: 20,000 contributions (~55/day)
Counts that high usually come from automation, so they leave you out of that tab and of the wider tabs whose counts include them. The limits measure volume, not how the activity is produced, so some very prolific people are over them too. Like the counts, they cover the last year, so you're back on a later refresh once your counts drop. If automation is what pushes you over, make those commits as a bot account (for example
github-actions[bot]) rather than your own, so they don't count towards your profile. If you think the limits are wrong, open an issue explaining why, but don't expect them to be loosened. -
Your location matches more than four of the site's locations, for example because it lists many countries. Rather than show such a profile on every one of their pages, it's left out of all of them. Some place names match more than one location, so list just the places you want to be ranked in.
Each tab ranks the 1,000 most-followed users by a different count over the last year, leaves out those above its yearly limits, and lists the top 256:
- Commits (the default): public commits.
- Contributions: all public contributions, such as commits, pull requests, issues and reviews.
- All: public and private contributions, for users who show private contributions on their profile.
Depending on your settings, your GitHub profile displays either only your public contributions or both your public and private ones. committers.top's default Commits tab counts only public commits; the Contributions tab counts all public contributions, and the All tab adds private ones. You can run the following query with the GitHub CLI to see what the API returns for your user:
gh api graphql -f query='
query {
viewer {
login
contributionsCollection {
totalCommitContributions
restrictedContributionsCount
contributionCalendar {
totalContributions
}
}
}
}'