feat(scoring): count languages from contributed repos, not just owned#39
Open
rainer-friederich wants to merge 1 commit into
Open
Conversation
Language diversity was scored only over a user's `ownerAffiliations: OWNER, isFork: false` repos, so a developer whose work lives in organisations they don't personally own (very common for professionals) scored "0 languages" — even with thousands of commits. Score languages over the UNION of owned repos and the public repos the user has recently committed to (contributionsCollection.commitContributionsByRepository), deduped by repo. A contributed repo counts only when it's public, non-fork, has a GitHub-classified primary language, and has at least MIN_CONTRIBUTED_LANG_COMMITS (3) commits in the last year, so a single drive-by fix can't inflate diversity. Private work stays a bare contribution count in GitHub's API, so it remains uncountable — this narrows the gap for org/team devs, it doesn't claim to close it. `repos` now feeds only the star signals; the new `languageRepos` feeds the language count + ranking. Covered by tests/signals.test.ts (signal decoupling) and new cases in tests/client.test.ts (query, threshold, fork/private/null exclusion, owned-vs-contributed dedup). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #38.
Problem
Language diversity (the
Dribbling/ "Technical range" stat) is scored only overownerAffiliations: OWNER, isFork: falserepos, so a developer whose work lives in organisations they don't personally own scores 0 languages — even with thousands of commits, PRs and reviews (all of which score fine, because they come fromcontributionsCollection). Owning a repo is only one way to work in a language.Fix
Score languages over the union of:
contributionsCollection.commitContributionsByRepository),deduped by repo. A contributed repo counts only when it is public, non-fork, has a GitHub-classified primary language, and has ≥
MIN_CONTRIBUTED_LANG_COMMITS(3) commits in the last year — so a single drive-by typo fix to a big polyglot repo can't inflate diversity.Honest limitation (documented in the issue): GitHub only exposes private activity as a bare
restrictedContributionsCount— no repo, no language — so private work still can't be counted. This narrows the gap for org/team devs; it doesn't close it.Shape of the change
lib/github/client.ts— profile query now also selectscommitContributionsByRepository { contributions { totalCount } repository { nameWithOwner isFork isPrivate primaryLanguage { name } } }(one extra field on the already-fetchedcontributionsCollection, so no extra request).normalize()builds a dedupedlanguageReposunion.RawPayload.reposnow feeds only the star signals; the newRawPayload.languageReposfeeds the language count + ranking.lib/github/signals.ts—languagesandrankLanguages()readlanguageRepos. Existing markup/styling demotion is unchanged, so a real language still headlines the card.No change to the public card shape, scoring weights, or the language→logo catalog.
Tests
npm test→ 116 passing (13 files). New coverage:tests/signals.test.ts— the signal decoupling: languages come fromlanguageRepos, stars fromrepos; the no-owned-public-repos (org-dev) case now scores languages; empty union → 0; markup demotion preserved.tests/client.test.ts— the query includescommitContributionsByRepository; the union folds contributed public repos and dedupes them against owned repos; forks / private repos / sub-threshold (<3 commits) / unclassified repos are excluded.npm run lint(0 new warnings) andnpm run build(types + prod build) both pass.Verification against a real account
Ran the new query/normalize logic against a live 11-year account that currently renders
0 languages: it now resolvesJavaScript(headline) +Makefilefrom its public org contributions — 0 → a real profile.🤖 Generated with Claude Code