Commit a318b59
authored
feat: limit calendar fetch concurrency to 5 in getOrgDashboardData to prevent 429 rate limits (JhaSourav07#2150)
## Description
Fixes JhaSourav07#2106
`getOrgDashboardData` was firing all member calendar fetches
simultaneously via an
uncapped `Promise.all`, creating a 1:1 ratio between org size and
parallel HTTP
requests. For large orgs (up to 200 members post-pagination fix), this
risks Vercel
serverless timeouts and GitHub secondary rate limits (429s).
This PR introduces a dependency-free `runCappedConcurrency` helper that
enforces a
maximum of 5 concurrent requests at any time, draining the queue as
slots free up.
**Changes made:**
- `lib/github.ts` — replaced uncapped `Promise.all` with
`runCappedConcurrency(tasks, 5)`;
appended the `runCappedConcurrency` helper at the end of the file
- `lib/github.test.ts` — imported `runCappedConcurrency`; added 3 unit
tests covering
result order preservation, strict concurrency cap enforcement, and
graceful
per-task failure recovery
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
N/A — internal data-fetching logic, no SVG output change.
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=Pranav-IIITM`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors.
- [x] My commits follow the Conventional Commits format (`feat: limit
calendar fetch concurrency to 5 in getOrgDashboardData to prevent 429
rate limits`).
- [ ] I have updated `README.md` if I added a new theme or URL
parameter. *(not applicable)*
- [x] I have started the repo.
- [x] I have made sure that i have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard. *(not applicable — no SVG changes)*
- [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.2 files changed
Lines changed: 83 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
2106 | 2107 | | |
2107 | 2108 | | |
2108 | 2109 | | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
713 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
714 | 716 | | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
721 | 721 | | |
722 | | - | |
| 722 | + | |
723 | 723 | | |
| 724 | + | |
724 | 725 | | |
725 | 726 | | |
726 | 727 | | |
| |||
1225 | 1226 | | |
1226 | 1227 | | |
1227 | 1228 | | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
0 commit comments