feat: Add all-time contributions support with deduplicated repository count#4644
feat: Add all-time contributions support with deduplicated repository count#4644banu4prasad wants to merge 55 commits into
Conversation
|
@banu4prasad is attempting to deploy a commit to the github readme stats Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for displaying all-time contribution statistics across a user's entire GitHub history, with automatic deduplication to count unique repositories only once even when a user has multiple contribution types (commits, issues, PRs, reviews) to the same repository.
Key Changes:
- Added
all_time_contribsquery parameter to enable fetching contributions across all years instead of just the last year - Implemented parallel fetching of contribution data using
Promise.all()with a 9-second timeout and graceful fallback - Extended cache duration for all-time stats (6 hours default vs 4 hours for standard stats)
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
src/fetchers/all-time-contributions.js |
New module that fetches contribution years and yearly data in parallel, deduplicating repositories across all contribution types |
src/fetchers/stats.js |
Integrated all-time contributions feature with timeout protection and fallback logic; removed some logger statements |
api/index.js |
Added parameter handling for all_time_contribs and custom cache logic for longer TTL |
src/common/envs.js |
Added ALL_TIME_CONTRIBS environment variable to enable/disable the feature globally |
src/cards/stats.js |
Added conditional label rendering to show "all time" vs "last year" based on parameter |
src/cards/types.d.ts |
Added TypeScript type definition for the new all_time_contribs option |
src/translations.js |
Added statcard.contribs-alltime translation key in 48 languages |
.gitignore |
Added .DS_Store to ignore macOS system files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…2617991897529006981 🔒 Fix Reflected XSS in API Status Endpoints
Replaced `curr.languages.edges.concat(acc)` with `acc.push(...curr.languages.edges)` to prevent recreating the accumulator array on each iteration. This reduces time complexity from O(N^2) to O(N). Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…at-9829857916427544140 ⚡ perf: optimize O(N^2) array concatenation in top-languages fetcher
This commit escapes the `secondaryMessage` inside `renderError` using `encodeHTML()` to prevent XSS vulnerabilities when generating SVG output. Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
Updates `api/status/pat-info.js` and `api/status/up.js` to return proper structured JSON using `res.json()` rather than sending unescaped strings or stringified JSON via `res.send()`. This explicitly sets the correct Content-Type ensuring browsers won't execute malicious error messages as HTML. Updates tests accordingly. Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
Changed the \`hide\` array filtering within \`renderStatsCard\` to use a \`Set\`. This changes the O(n) \`.includes()\` lookup to an O(1) \`.has()\` lookup. Applied to both stat items filtering and accessibility labels. Performance baseline measured using \`tests/bench/stats.bench.js\`: Before: avg ~32.5µs After: avg ~26.9µs Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…cess-11153830499985198609 ⚡ Optimize object property access in top languages fetcher
…s-410756806148804890 ⚡ Optimize hidden stats array lookups with Set
…ints
Updates `api/status/pat-info.js` and `api/status/up.js` error handling to explicitly return a JSON object using `res.json({ error: ... })` instead of sending strings through `res.send()`. This enforces strict API consistency and mitigates any theoretical HTML rendering issues, resolving potential XSS concerns. Note this is a breaking change for existing clients directly parsing the raw string error response. Tests have been updated to cover the new outer catch payload structure.
Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…ints
Updates `api/status/pat-info.js` and `api/status/up.js` error handling to explicitly return a JSON object using `res.json({ error: ... })` instead of sending strings through `res.send()`. This enforces strict API consistency and corrects the API behavior since the endpoint explicitly sets `Content-Type: application/json`. Tests have been updated to cover the new outer catch payload structure.
Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…410205025217312 🔒 Fix Reflected XSS Vulnerability in PAT Info and Uptime Endpoints
This commit escapes the `secondaryMessage` inside `renderError` using `encodeHTML()` to prevent XSS vulnerabilities when generating SVG output. Also avoids double-escaping regression. Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
This commit escapes the `secondaryMessage` inside `renderError` using `encodeHTML()` to prevent XSS vulnerabilities when generating SVG output. Also avoids double-escaping regression and adds robust tests. Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…ry-message-14295917276723695873 🔒 Fix unescaped secondaryMessage XSS vulnerability in renderError
…utions.js` Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…utions.js` Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…utions.js` Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…utions.js` Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…utions.js` Co-authored-by: banu4prasad <113224132+banu4prasad@users.noreply.github.com>
…-219987405495775010 ⚡ perf: optimize batch processing in all-time contributions with worker pool
|
@banu4prasad why was this closed? 👀 |
@dargmuesli cuz i have edited too many files which was not related to the PR |
Summary
Adds support for displaying all-time contributions across all years on GitHub, with automatic deduplication of repositories to show accurate unique contribution counts.
Changes
all_time_contribsparameter to toggle between last year and all-time contributionsALL_TIME_CONTRIBSenvironment variable to enable/disable feature globallyUsage
Standard (last year only)
?username=YOUR_USERNAME
All-time contributions (deduplicated)
?username=YOUR_USERNAME&all_time_contribs=true
Environment Variables
ALL_TIME_CONTRIBS=true- Enable all-time contributions featurePAT_1=<github_token>- GitHub Personal Access Token withread:userscopefixes #2282