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>| Option | Type | Required | What it is |
|---|---|---|---|
username | string | undefined | yes | — |
include_all_commits | boolean | undefined | no | — |
exclude_repo | string[] | undefined | no | — |
include_merged_pull_requests | boolean | undefined | no | — |
include_discussions | boolean | undefined | no | — |
include_discussions_answers | boolean | undefined | no | — |
from | Date | undefined | no | Start of the range the commit count covers; GitHub's own last year when neither end is given. |
to | Date | undefined | no | End of that range. |
repo | string[] | undefined | no | — |
owner | string[] | undefined | no | — |
include_prs_authored | boolean | undefined | no | — |
include_prs_commented | boolean | undefined | no | — |
include_prs_reviewed | boolean | undefined | no | — |
include_issues_authored | boolean | undefined | no | — |
include_issues_commented | boolean | undefined | no | — |
ownerAffiliations | string[] | undefined | no | — |
include_contributions | boolean | undefined | no | — |
include_all_time_contribs | boolean | undefined | no | — |
contribs_include_own_repos | boolean | undefined | no | — |
Returns Promise<StatsData> — Stats data.
What it costs
Section titled “What it costs”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.
The range
Section titled “The range”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.
The rank
Section titled “The rank”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.