Skip to content

fix: use viewer query, rolling date window, and all-time history support#147

Open
K-H-A-L-I-D wants to merge 8 commits intoyoshi389111:mainfrom
K-H-A-L-I-D:main
Open

fix: use viewer query, rolling date window, and all-time history support#147
K-H-A-L-I-D wants to merge 8 commits intoyoshi389111:mainfrom
K-H-A-L-I-D:main

Conversation

@K-H-A-L-I-D
Copy link
Copy Markdown

@K-H-A-L-I-D K-H-A-L-I-D commented Apr 14, 2026

GitHub's contributionsCollection query returns only public contributions when accessed through user(login: $login). Both GraphQL queries in fetchFirst and fetchNext now use viewer instead, so the data reflects the full activity of whoever owns the token. The ResponseType and ResponseNextType types update accordingly from data.user to data.viewer.

The date range behavior changes when no YEAR is set. The original code passed no filter to contributionsCollection, and GitHub's API defaults that to the current calendar year. Anyone running the action in January sees one month of bars. The fix computes a rolling 12-month window explicitly, giving a consistent full-year view regardless of when the action runs.

Three new environment variables add opt-in behavior for users who want more than one year of history.

ALL_TIME=true fetches the complete contribution history. The action queries viewer { createdAt } to find the account creation year, fetches each calendar year in sequence, and merges the contribution calendars before rendering. It makes one extra API call per year of account history. The resulting SVG covers every week since the account was created, which can produce a very wide graph for older accounts.

ALL_TIME_LANGS=true is a lighter alternative. It keeps the 52-week calendar window so the SVG renders at normal size, but pulls commitContributionsByRepository across every year to build the language pie. The total contribution count displayed in the graph also reflects the full account history rather than just the visible window. This is the recommended flag for most users who want accurate language attribution without the rendering cost of a multi-year calendar.

The package.json clean script gets a small fix as well. rimraf dist/* fails on Windows with rimraf v6 because glob patterns require an explicit flag. Changing it to rimraf --glob dist/* makes local builds work cross-platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant