feat(launch): cap per-user language fetch at 40 repos, raise enrollment caps, fix cap message

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shay
2026-11-29 10:30:52 -08:00
co-authored by Claude Opus 5.5
parent e47a67d1a1
commit 53ae54fe98
7 changed files with 50 additions and 5 deletions
+27
View File
@@ -250,3 +250,30 @@ def test_rate_limited_repo_languages_aborts_whole_fetch():
repos = [{"full_name": "alice/proj"}]
with pytest.raises(github.GitHubTransientError):
github._enrich_repo_languages(repos, src)
def test_repo_languages_capped_to_recent_owned_repos(monkeypatch):
# One REST call per repo, so only the most recently pushed non-fork repos
# the user owns get a byte breakdown.
monkeypatch.setattr(github.config, "LANGUAGE_MAX_REPOS", 2)
class _Src:
def __init__(self):
self.calls = []
def fetch_repo_languages(self, full_name):
self.calls.append(full_name)
return {"Python": 1}
repos = [
{"full_name": "Alice/old", "pushed_at": "2024-01-01T00:00:00Z"},
{"full_name": "alice/new", "pushed_at": "2026-01-01T00:00:00Z"},
{"full_name": "alice/mid", "pushed_at": "2025-01-01T00:00:00Z"},
{"full_name": "alice/fork", "pushed_at": "2026-06-01T00:00:00Z", "fork": True},
{"full_name": "org/other", "pushed_at": "2026-06-01T00:00:00Z"},
]
src = _Src()
github._enrich_repo_languages(repos, src, "alice")
assert sorted(src.calls) == ["alice/mid", "alice/new"]
assert repos[1]["language_bytes"] == {"Python": 1}
assert "language_bytes" not in repos[0]