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

'include_all_commits' doesn't work properly with 'count_private'.

Open Taiizor opened this issue 3 years ago • 3 comments

Describe the bug The commit count does not work correctly at all times.

Expected behaviour Correct operation of total commit count at all times (including hidden commits).

Screenshots / Live demo link (paste the github-readme-stats link as markdown image) image

image

Additional context Working properly: https://github-readme-stats.vercel.app/api?username=Taiizor&show_icons=true&theme=tokyonight&count_private=true

Not working properly: https://github-readme-stats.vercel.app/api?username=Taiizor&show_icons=true&theme=tokyonight&count_private=true&include_all_commits=true

Taiizor avatar Sep 21 '22 17:09 Taiizor

Having the same issue with mine. Here is what my stats card looks like with include_all_commits=false vs include_all_commits=true

include_all_commits-false include_all_commits-true

Some obvious errors with the include_all_commits and flagging it as true.

akielaries avatar Sep 21 '22 23:09 akielaries

It's working as it should now.

Taiizor avatar Sep 22 '22 08:09 Taiizor

am still getting some errors with mine unfortunately

akielaries avatar Sep 22 '22 08:09 akielaries

@Taiizor and @akielaries, I checked the codebase, and I think both count_private and include_all_commits parameters are correctly implemented.

https://github.com/anuraghazra/github-readme-stats/blob/9a909ff0a41a6abba34b008ce57744d7cb2cd220/src/fetchers/stats-fetcher.js#L155-L163

I, therefore, think the error is caused by incorrect data returned from GitHub's REST API and GraphQL API APIs. If this happens, these wrong values are cached for 4 hours.

https://github.com/anuraghazra/github-readme-stats/blob/9a909ff0a41a6abba34b008ce57744d7cb2cd220/api/index.js#L60-L64

When this happens, you can check the console.log to see if there is any error and use the &v=123 syntax to force the cache to reload.

Detailed explanation

If include_all_commits is enabled, and GitHub REST API fails the code will return 0.

https://github.com/anuraghazra/github-readme-stats/blob/9a909ff0a41a6abba34b008ce57744d7cb2cd220/src/fetchers/stats-fetcher.js#L69-L100

This will then be used as the total commits. To this value, the private commits will be correctly added if count_private is enabled. Since we used caching, this wrong value will be on the card for 4 hours.

Posible solutions

We can use the previous cache when this problem happens.

rickstaa avatar Sep 24 '22 14:09 rickstaa

Duplicate of #1515.

rickstaa avatar Sep 24 '22 14:09 rickstaa