Skip to content

fetchStats

The fetcher behind the stats card, and the most expensive one here: each of the optional counts is another request, which is why they are flags rather than defaults.

Fetch stats for a given username.

fetchStats(options, config: CardConfig): Promise<StatsData>
OptionTypeRequiredWhat it is
usernamestring | undefinedyes
include_all_commitsboolean | undefinedno
exclude_repostring[] | undefinedno
include_merged_pull_requestsboolean | undefinedno
include_discussionsboolean | undefinedno
include_discussions_answersboolean | undefinedno
fromDate | undefinednoStart of the range the commit count covers; GitHub's own last year when neither end is given.
toDate | undefinednoEnd of that range.
repostring[] | undefinedno
ownerstring[] | undefinedno
include_prs_authoredboolean | undefinedno
include_prs_commentedboolean | undefinedno
include_prs_reviewedboolean | undefinedno
include_issues_authoredboolean | undefinedno
include_issues_commentedboolean | undefinedno
ownerAffiliationsstring[] | undefinedno
include_contributionsboolean | undefinedno
include_all_time_contribsboolean | undefinedno
contribs_include_own_reposboolean | undefinedno

Returns Promise<StatsData> — Stats data.

The five default numbers come from one GraphQL call. Everything switched on with an include_* flag — merged pull requests, discussions, reviews, the issue and PR searches — is a further request against the search API, which has its own tighter rate limit. Ask for what a card draws, nothing more.

from and to bound the commits and contributions counted, both ends inclusive. GitHub answers a contributions query for at most a year at a time, so a wider range is sliced into one query per calendar year and sent as fields of a single request.

rank is computed here rather than by GitHub: a percentile over commits, pull requests, issues, reviews, stars and followers, graded into C through S. It comes back on the same object, so a consumer drawing its own card need not reimplement it.