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
+4
View File
@@ -31,5 +31,9 @@ DEEP_COLLAB_THRESHOLD = int(os.getenv("DEEP_COLLAB_THRESHOLD", "25"))
COMMIT_MAX_REPOS = int(os.getenv("COMMIT_MAX_REPOS", "10"))
COMMIT_PER_REPO = int(os.getenv("COMMIT_PER_REPO", "30"))
# Per-repo language-bytes fetches: one REST call each, so cap them to the
# most recently pushed repos the user owns (forks excluded).
LANGUAGE_MAX_REPOS = int(os.getenv("LANGUAGE_MAX_REPOS", "40"))
ANALYTICS_FLUSH_SECONDS = int(os.getenv("ANALYTICS_FLUSH_SECONDS", "5"))
ANALYTICS_QUEUE_MAX = int(os.getenv("ANALYTICS_QUEUE_MAX", "2000"))
+8 -2
View File
@@ -714,7 +714,7 @@ def fetch_github_data(
avatar_b64 = ""
avatar_url = user.get("avatar_url") if isinstance(user, dict) else None
with ThreadPoolExecutor(max_workers=2, thread_name_prefix="fetch-stage2") as pool:
fut_lang = pool.submit(_enrich_repo_languages, repos, source)
fut_lang = pool.submit(_enrich_repo_languages, repos, source, username)
fut_avatar = pool.submit(source.fetch_avatar, avatar_url) if avatar_url else None
fut_lang.result()
if fut_avatar is not None:
@@ -733,13 +733,19 @@ def fetch_github_data(
}
def _enrich_repo_languages(repos: list, source: GitHubDataSource) -> None:
def _enrich_repo_languages(repos: list, source: GitHubDataSource, username: str = "") -> None:
"""Mutates `repos` in-place, attaching `language_bytes: {lang: bytes}` to
each repo. Uses a small thread pool — one REST call per repo is cheap
individually, but sequentially N repos would block the fetch noticeably."""
if not repos:
return
names = [(i, r["full_name"]) for i, r in enumerate(repos) if r.get("full_name")]
if username:
owner = username.lower()
names = [(i, fn) for i, fn in names
if not repos[i].get("fork") and fn.split("/")[0].lower() == owner]
names.sort(key=lambda p: repos[p[0]].get("pushed_at") or "", reverse=True)
names = names[:config.LANGUAGE_MAX_REPOS]
print(f" Fetching language byte breakdown for {len(names)} repos...")
with ThreadPoolExecutor(max_workers=10) as pool:
futures = {pool.submit(source.fetch_repo_languages, fn): i for i, fn in names}