-
-
Notifications
You must be signed in to change notification settings - Fork 23.2k
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
fix: fetch all repos for top languages #1178
Conversation
@tc-imba is attempting to deploy a commit to the github readme stats Team on Vercel. A member of the Team first needs to authorize it. |
@anuraghazra any comments? |
any updates to this? |
My status is off by a considerable margin because of this, please give it some attention since it`s a critical bug for the cards |
@Jordhan-Carvalho Thanks for your comment. We sadly did not have the time to look at this pull request, but we are aware of the problem (see #1852 and #1801). To speed up the PR merging process, people can best show their support by giving a 👍🏻 to #1178 and #1852. Doing this will provide us with an idea of how many users are affected (see the Top features dashboard). |
@@ -37,14 +43,28 @@ const fetcher = (variables, token) => { | |||
async function fetchTopLanguages(username, exclude_repo = []) { | |||
if (!username) throw Error("Invalid username"); | |||
|
|||
const res = await retryer(fetcher, { login: username }); | |||
const pageSize = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use the pageInfo object to get cleaner code. 🚀
// Loop through all pages and fetch all repos
let repoNodes = [];
let hasNextPage = true
let endCursor = null
while (hasNextPage) {
const variables = { login: username, first: 100, after: endCursor };
const res = await retryer(fetcher, variables);
if (res.data.errors) {
logger.error(res.data.errors);
throw Error(res.data.errors[0].message || "Could not fetch user");
}
repoNodes.push(...res.data.data.user.repositories.nodes);
hasNextPage = res.data.data.user.repositories.pageInfo.hasNextPage
endCursor = res.data.data.user.repositories.pageInfo.endCursor
}
@tc-imba, @Jordhan-Carvalho, I found some time today to review this pull request. Overall it looks good to me! 🚀 I would, however, use the pageInfo object to get cleaner code. @tc-imba is there a reason you are using the cursor instead? |
replaced by #2111. |
This fixed #1177
Before:
After:
PS. I have some python repos recently but not shown in the first figure because they are not in the oldest 100 repos. In the second figure they are successfully found.