Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide border option influences commit count #2026

Closed
klieret opened this issue Sep 15, 2022 · 7 comments
Closed

Hide border option influences commit count #2026

klieret opened this issue Sep 15, 2022 · 7 comments

Comments

@klieret
Copy link

klieret commented Sep 15, 2022

Description

Hide border option influences total commit count

Live

Anurag's GitHub stats

Anurag's GitHub stats

Anurag's GitHub stats

Screenshot of the above (15 Sep 2022)

image

@rickstaa
Copy link
Collaborator

@klieret Thanks for your bug report. I can not think of how the hide_border option can break the card:

stroke-opacity="${this.hideBorder ? 0 : 1}"

I have heard reports from others (i.e. #1963 and #1968), but those were related to caching or syntax errors. Can you maybe provide me with the syntax you're using for generating the card?

@klieret
Copy link
Author

klieret commented Sep 16, 2022

Thank you for your quick reply! I'm also quite puzzled. My only hypothesis that there might be some parsing error, (perhaps due to wrong syntax on my side - though I can't think of something) that causes some other options to be triggered...

The syntax should be included above (it's live markdown), but let me quickly copy it:

Hide border
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=klieret&hide_border=true&show_icons=true&count_private=true&include_all_commits=true)

Explicitly show border
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=klieret&hide_border=false&show_icons=true&count_private=true&include_all_commits=true)

No border argument
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=klieret&show_icons=true&count_private=true&include_all_commits=true)

are the three cards.

@rickstaa
Copy link
Collaborator

rickstaa commented Sep 17, 2022

@klieret Ah, sorry, I thought all were screenshots. I checked your syntax, and it is correct 👍🏻.

Hide border

![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=klieret&hide_border=true&show_icons=true&count_private=true&include_all_commits=true)

Anurag's GitHub stats

Explicitly show border

![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=klieret&hide_border=false&show_icons=true&count_private=true&include_all_commits=true)

Anurag's GitHub stats

No border argument

![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=klieret&show_icons=true&count_private=true&include_all_commits=true)

Anurag's GitHub stats

After inspecting the codebase, I don't think a parsing error of the hide_border can affect the commit count. I created #2029, to be sure. What I think is happening is that there is a temporary problem with GitHub's REST API, and the incorrect commit count gets stored in the cache and stays on the card for 4 hours.

const totalCommitsFetcher = async (username) => {
if (!githubUsernameRegex.test(username)) {
logger.log("Invalid username");
return 0;
}
// https://developer.github.com/v3/search/#search-commits
const fetchTotalCommits = (variables, token) => {
return axios({
method: "get",
url: `https://api.github.com/search/commits?q=author:${variables.login}`,
headers: {
"Content-Type": "application/json",
Accept: "application/vnd.github.cloak-preview",
Authorization: `token ${token}`,
},
});
};
try {
let res = await retryer(fetchTotalCommits, { login: username });
let total_count = res.data.total_count;
if (!!total_count && !isNaN(total_count)) {
return res.data.total_count;
}
} catch (err) {
logger.log(err);
}
// just return 0 if there is something wrong so that
// we don't break the whole app
return 0;
};

Maybe if you see it happen again, can you check whether an error or warning is thrown inside the browser's console? 🤔 Feel free to comment below if the issue happens again.

@klieret
Copy link
Author

klieret commented Sep 19, 2022

Thanks a lot! Indeed things are back to normal now, so it must have been a REST API hickup...

I'll check in the console if something like this happens again!

@klieret
Copy link
Author

klieret commented Jan 9, 2023

Hi @rickstaa. Just letting you know that I observed the same issue again today (a completely wrong commit count)
image

(should be something like 7k).

I don't see relevant warnings in the browser console.

@rickstaa
Copy link
Collaborator

rickstaa commented Jan 10, 2023

@klieret, thanks for letting me know. I checked, and the commit count seems to be back on 8k again. This problem happens from time to time because GitHub's REST API gives us wrong data or timeout. The only thing I can do to alleviate it is merged #2177. It will be fixed when #2179 is created since I can then use the GraphQL API, which is less buggy, and sum the commits per year.

@lukaszmielczarekdev
Copy link

I managed to make it work by setting count_private property to true.

https://github-readme-stats.vercel.app/api?username=lukaszmielczarekdev&theme=dark&hide_border=true&include_all_commits=true&count_private=true

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

No branches or pull requests

3 participants