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
Open
fix: use viewer query, rolling date window, and all-time history support#147K-H-A-L-I-D wants to merge 8 commits intoyoshi389111:mainfrom
K-H-A-L-I-D wants to merge 8 commits intoyoshi389111:mainfrom
Conversation
…private contributions
…ad of current calendar year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub's
contributionsCollectionquery returns only public contributions when accessed throughuser(login: $login). Both GraphQL queries infetchFirstandfetchNextnow useviewerinstead, so the data reflects the full activity of whoever owns the token. TheResponseTypeandResponseNextTypetypes update accordingly fromdata.usertodata.viewer.The date range behavior changes when no
YEARis set. The original code passed no filter tocontributionsCollection, 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=truefetches the complete contribution history. The action queriesviewer { 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=trueis a lighter alternative. It keeps the 52-week calendar window so the SVG renders at normal size, but pullscommitContributionsByRepositoryacross 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.jsonclean script gets a small fix as well.rimraf dist/*fails on Windows with rimraf v6 because glob patterns require an explicit flag. Changing it torimraf --glob dist/*makes local builds work cross-platform.