GitHub contributor ranking and concentration
Ranks a repository's contributors by commit count and shows how concentrated the contributions are. The running total and percentage share answer the bus factor question directly: if the top one or two logins account for most of the total, the project has a single-maintainer risk.
Query
SELECT
login,
contributions,
DENSE_RANK() OVER (ORDER BY contributions DESC) as contribution_rank,
SUM(contributions) OVER (ORDER BY contributions DESC) as running_total,
SUM(contributions) OVER () as total_contributions,
ROUND(100.0 * contributions / SUM(contributions) OVER (), 2) as pct_of_total
FROM github.repos.contributors
WHERE owner = '{{owner}}'
AND repo = '{{repo}}';
Variation: contributor tiers
NTILE splits the ranking into quartiles, which is a stable way to label contributors without hardcoding thresholds:
SELECT
login,
contributions,
NTILE(4) OVER (ORDER BY contributions DESC) as contribution_quartile,
CASE NTILE(4) OVER (ORDER BY contributions DESC)
WHEN 1 THEN 'Top Contributors'
WHEN 2 THEN 'Active Contributors'
WHEN 3 THEN 'Moderate Contributors'
WHEN 4 THEN 'Occasional Contributors'
END as contributor_tier
FROM github.repos.contributors
WHERE owner = '{{owner}}'
AND repo = '{{repo}}';
Variation: ranking functions compared
The three ranking functions differ only in how they treat ties, which matters when several contributors share a commit count:
SELECT
login,
contributions,
RANK() OVER (ORDER BY contributions DESC) as rank,
DENSE_RANK() OVER (ORDER BY contributions DESC) as dense_rank,
ROW_NUMBER() OVER (ORDER BY contributions DESC) as row_num,
ROUND(PERCENT_RANK() OVER (ORDER BY contributions), 3) as percentile
FROM github.repos.contributors
WHERE owner = '{{owner}}'
AND repo = '{{repo}}';
Notes
running_total uses the default window frame, which includes all peer rows at the same contribution count, so tied contributors share an identical running total and the column jumps rather than incrementing one row at a time - that is correct SQL, not a defect, but it makes the column unsuitable as a sequence number. Use ROW_NUMBER for that. RANK leaves gaps after a tie while DENSE_RANK does not, and ROW_NUMBER breaks ties arbitrarily; the template uses DENSE_RANK so equal contributors read as equal. PERCENT_RANK orders ascending, so the largest contributor scores 1. The contributors endpoint counts commits to the default branch only and excludes merge commits, so the totals will not match a repository's full commit history. Anonymous contributors are omitted unless requested.