Skip to content

Commit 47f9d68

Browse files
author
Anush Kamble
committed
fix: cap org dashboard active members at 60 to reduce shared token API consumption (JhaSourav07#2249)
Problem: - getOrgDashboardData fetches contribution calendars for up to 200 members (4 pages x 50 per page) via fetchGitHubContributions - Even with concurrency capped at 5 (PR JhaSourav07#2150), the total volume of GraphQL calls per org request is 200 x ~5 points = ~1000 points - With the shared GITHUB_TOKEN at 5000 points/hr, only 5 org dashboard requests per hour are possible before all users are rate-limited Fix: - Limit activeMembers to first 60 by slicing the members array before dispatching contribution fetches - 60 members covers the most active contributors for any org size while cutting worst-case API consumption by 70% (1000 -> 300 points/request) - The member list is already sorted by join date from the REST API; the first 60 members are typically the most active contributors - Combined with concurrency cap (5) and TTL cache, this makes org dashboard viable without exhausting the shared token Related: PR JhaSourav07#2150 (concurrency), PR JhaSourav07#2149 (pagination) Fixes JhaSourav07#2249
1 parent 348372a commit 47f9d68

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/github.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,12 @@ export async function getOrgDashboardData(orgName: string, options: FetchOptions
747747
throw new Error('This endpoint is strictly for organizations.');
748748
if (membersOrError instanceof Error) throw membersOrError;
749749

750-
const members = membersOrError;
750+
// Limit active members to first 60 to protect shared token rate limit
751+
const activeMembers = members.slice(0, 60);
751752

752753
// Fetch calendars for all members concurrently with capped concurrency to avoid 429s/timeouts
753754
const calendars = (
754-
await runCappedConcurrency(members, 5, (member) =>
755+
await runCappedConcurrency(activeMembers, 5, (member) =>
755756
fetchGitHubContributions(member, options)
756757
.then((data) => data.calendar)
757758
.catch(() => null)

0 commit comments

Comments
 (0)