Skip to content

Commit af30c96

Browse files
authored
[CRITICAL] fix: cap org dashboard active members at 60 to reduce shared token API consumption (JhaSourav07#2249) (JhaSourav07#2257)
## Description This PR closes JhaSourav07#2249 by adding the remaining safeguard not covered by PRs JhaSourav07#2150 (concurrency limit) and JhaSourav07#2149 (member pagination). ### Problem The organization dashboard still exhausts the shared GITHUB_TOKEN rate limit too quickly. Even with concurrency capped at 5 and pagination fetching up to 200 members, a single org dashboard request can consume ~1000 GraphQL points out of a 5000 points/hour budget. Only ~5 org dashboard requests per hour are possible before ALL users are rate-limited. ### How I Fixed It Capped active members at 60 before dispatching contribution fetches. This means: - 60 members x 5 points = ~300 points per request (70% reduction from 200-member worst case) - runCappedConcurrency still limits concurrency to 5 at a time - fetchGitHubContributions still uses its TTL cache - The REST API returns members roughly sorted by join date; the first 60 are the most active ### Changes - `lib/github.ts` - Added `const activeMembers = members.slice(0, 60)` before contribution fetch dispatch ## Pillar - [ ] Pillar 1 - New Theme Design - [ ] Pillar 2 - Geometric SVG Improvement - [ ] Pillar 3 - Timezone Logic Optimization - [x] Other (Bug fix, performance) ## Checklist before requesting a review - [x] I have read the CONTRIBUTING.md file - [x] I have tested these changes locally (npm run format:check, npm run lint, npm run typecheck, npm run test, npm run build) - [x] I have run npm run format and npm run lint locally and resolved all errors - [x] My commits follow the Conventional Commits format - [ ] I have updated README.md if I added a new theme or URL parameter (not applicable) - [x] I have starred the repo Closes JhaSourav07#2249
2 parents f0f56a8 + 81d8880 commit af30c96

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/github.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,12 @@ export async function getOrgDashboardData(orgName: string, options: FetchOptions
749749

750750
const members = membersOrError;
751751

752+
// Limit active members to first 60 to protect shared token rate limit
753+
const activeMembers = members.slice(0, 60);
754+
752755
// Fetch calendars for all members concurrently with capped concurrency to avoid 429s/timeouts
753756
const calendars = (
754-
await runCappedConcurrency(members, 5, (member) =>
757+
await runCappedConcurrency(activeMembers, 5, (member) =>
755758
fetchGitHubContributions(member, options)
756759
.then((data) => data.calendar)
757760
.catch(() => null)

0 commit comments

Comments
 (0)