github-readme-stats icon indicating copy to clipboard operation
github-readme-stats copied to clipboard

fix: prevent totalCommitsFetch error result from being cached

Open rickstaa opened this issue 3 years ago • 5 comments

This PR ensures that when the https://api.github.com/search/commits?q=author:anuraghazra API fails, the result is not cached. This prevents people from creating an issue because their commits are 0 for the 4-hour cache period. After this PR is merged, the 0 total commits should only show up when the error occurs.

rickstaa avatar Oct 10 '22 11:10 rickstaa

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
github-readme-stats ✅ Ready (Inspect) Visit Preview Jan 10, 2023 at 10:24AM (UTC)

vercel[bot] avatar Oct 10 '22 11:10 vercel[bot]

Codecov Report

Base: 96.79% // Head: 97.23% // Increases project coverage by +0.43% :tada:

Coverage data is based on head (6c2d175) compared to base (227711c). Patch coverage: 94.23% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2177      +/-   ##
==========================================
+ Coverage   96.79%   97.23%   +0.43%     
==========================================
  Files          22       22              
  Lines        3835     3902      +67     
  Branches      328      368      +40     
==========================================
+ Hits         3712     3794      +82     
+ Misses        121      106      -15     
  Partials        2        2              
Impacted Files Coverage Δ
api/index.js 94.33% <85.71%> (-1.62%) :arrow_down:
src/fetchers/stats-fetcher.js 92.41% <97.36%> (+1.40%) :arrow_up:
src/cards/top-languages-card.js 100.00% <0.00%> (ø)
src/common/createProgressNode.js 100.00% <0.00%> (ø)
api/top-langs.js 97.67% <0.00%> (+2.43%) :arrow_up:
src/common/retryer.js 98.43% <0.00%> (+19.74%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Oct 10 '22 11:10 codecov[bot]

@anuraghazra, maybe we can merge this this will stop people making issues about incorrect total commit count (See https://github.com/anuraghazra/github-readme-stats/issues/2026#issuecomment-1376309417).

rickstaa avatar Jan 10 '23 12:01 rickstaa

@anuraghazra Closing this for now. See https://github.com/anuraghazra/github-readme-stats/pull/2177#discussion_r1071112093, as it might also be important.

rickstaa avatar Jan 16 '23 11:01 rickstaa

Re-opening this since we can use this code on private Vercel instances.

rickstaa avatar Jan 20 '23 08:01 rickstaa

Closing this as I think we should switch to throwing an error when the REST API fails and then use stale-if-error to handle the PAT depletion (see https://github.com/anuraghazra/github-readme-stats/pull/2448#issuecomment-1399296739).

rickstaa avatar Jan 21 '23 17:01 rickstaa

Closing this as I think we should switch to throwing an error when the REST API fails and then use stale-if-error to handle the PAT depletion (see #2448 (comment)).

stale-if-error seems like a great idea! That will stop the PAT error from showing up during downtime, and since downtime is always less than 1 hour, it can automatically refresh the cache after 1 hour.

Zo-Bro-23 avatar Jan 22 '23 02:01 Zo-Bro-23