fix(stats): split GraphQL queries to avoid resource limits#375
fix(stats): split GraphQL queries to avoid resource limits#375Dendroculus wants to merge 2 commits into
Conversation
|
@Dendroculus is attempting to deploy a commit to the martin-mfg's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Confirming this fixes a real account (re: #373). My profile card (user
That last one is why splitting alone isn't enough for my account: |
Splits the bundled stats query into separate requests and drops repositoriesContributedTo to null when GitHub rejects it, so accounts that hit the per-query resource limit still render. Applies PR stats-organization#375 from stats-organization/github-stats-extended ahead of the upstream merge. Revert with a reset to upstream master once stats-organization#375 lands there.
Splits the bundled stats query into separate requests and drops repositoriesContributedTo to null when GitHub rejects it, so accounts that hit the per-query resource limit still render. Applies PR stats-organization#375 from stats-organization/github-stats-extended ahead of the upstream merge. Revert with a reset to upstream master once stats-organization#375 lands there.

What changed
RESOURCE_LIMITS_EXCEEDEDfromrepositoriesContributedToas non-fatalnullwhen the contributed-repositories metric is unavailableWhy
GitHub's GraphQL API can reject statistics queries with:
RESOURCE_LIMITS_EXCEEDEDTesting against
domdfcodingshowed thatrepositoriesContributedTocan exceed GitHub's resource limit even when queried separately. The remaining statistics are still available, so this optional metric should not prevent the entire card from rendering.Fixes #373
Validation
git diff --checkpassedDendroculusdomdfcodingDendroculusrenders with the contributed-repositories metricdomdfcodingrenders successfully withoutRESOURCE_LIMITS_EXCEEDED, omitting the unavailable contributed-repositories metricCredit
Thank you to @domdfcoding for suggesting that the query should be split into smaller requests.
Thank you to @nightt5879 for the detailed investigation in #373 and for providing the reference implementation in anuraghazra#4916.
This PR adapts and extends that approach for GitHub Stats Extended while preserving its existing pagination, owner-affiliation, PAT, repository-exclusion, and cache-handling behavior.