Skip to content

feat(commits): add highly optimized advanced mode for all-time stats and custom ranges via single GraphQL request#4890

Open
JessicaKei wants to merge 19 commits into
anuraghazra:masterfrom
JessicaKei:feat/graphql-all-time-commits-range
Open

feat(commits): add highly optimized advanced mode for all-time stats and custom ranges via single GraphQL request#4890
JessicaKei wants to merge 19 commits into
anuraghazra:masterfrom
JessicaKei:feat/graphql-all-time-commits-range

Conversation

@JessicaKei

Copy link
Copy Markdown

🚀 Description

This PR introduces an advanced mode for the commits API using GitHub's GraphQL API. Crucially, it fetches the entire all-time commit history or custom year ranges efficiently in a SINGLE, highly optimized GraphQL request. Unlike previous community attempts, it completely avoids any loop-based request spamming or pagination overhead, bypassing the limitations of the default REST/Search implementation with minimal performance impact.

🛑 Zero Impact on Existing Logic (Non-breaking Extension)

  • Completely Isolated: The core codebase and the application's default execution paths have not been overridden or altered in any way.
  • Opt-in Only: This functionality acts strictly as a non-intrusive extension. By default, it remains completely inactive and untouched. It is explicitly triggered only if a user passes commits_api=advanced in their query parameters.

🛠️ Features Added:

  • All-Time Commits: Tracks public commits since account creation via commits_api=advanced.
  • Private Commits Support: Extends all-time tracking to private repositories when include_all_commits=true is provided.
  • Custom Year Ranges: Seamlessly handles date ranges when paired with commits_year and commits_end_year.
  • Strict Sanitation: Includes input validation for the new API parameter to prevent unexpected behavior.

🛡️ Server-Side Safety (Feature Toggle)

To eliminate any performance or rate-limiting concerns on the public production deployment, I have introduced a feature toggle:

  • Setting DISABLE_ADVANCED_COMMITS=true completely disables this feature globally and safely falls back to the default behavior. It's a bulletproof solution for public instances while keeping the feature fully available for self-hosted deployments.

🧪 Quality Assurance

  • Full Test Coverage: All newly introduced functions, parameter validations, and execution paths are 100% covered by new unit tests written specifically for this feature.
  • Backward Compatibility: Existing tests remain untouched and functional. All 249 tests are passing successfully, maintaining a file coverage of 99.07%.
  • Code Style: Verified and passed via linter.
  • Documentation: Updated README.md with new parameters, types, notes on case-sensitivity, fallback behaviors, and environment variables.

JessicaKei added 19 commits May 22, 2026 02:55
Introduced a server-side environment variable to safely disable the advanced commits API functionality if needed. Defaults to enabled.
…ecking

Added getValidatedCommitsApiValue helper to validate incoming API values against allowed types. Refactored stats fetcher to use the validated commitsApi variable.
…ITS variable

Updated the parameters table with commits_api and commits_end_year options. Expanded include_all_commits and commits_year descriptions, and documented the DISABLE_ADVANCED_COMMITS environment variable.
@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown

@JessicaKei is attempting to deploy a commit to the github readme stats Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added documentation Improvements or additions to documentation. stats-card Feature, Enhancement, Fixes related to stats the stats card. labels May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation. stats-card Feature, Enhancement, Fixes related to stats the stats card.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant