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

fix: fetch all repos for top languages #1178

Closed
wants to merge 2 commits into from

Conversation

tc-imba
Copy link

@tc-imba tc-imba commented Jul 8, 2021

This fixed #1177

Before:
Top Langs

After:
Top Langs

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.

@vercel
Copy link

vercel bot commented Jul 8, 2021

@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.

@tc-imba
Copy link
Author

tc-imba commented Jul 18, 2021

@anuraghazra any comments?

@IamManchanda
Copy link

any updates to this?

@Jordhan-Carvalho
Copy link

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

@rickstaa
Copy link
Collaborator

rickstaa commented Sep 16, 2022

@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;
Copy link
Collaborator

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
  }

@rickstaa
Copy link
Collaborator

@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?

@rickstaa
Copy link
Collaborator

rickstaa commented Oct 8, 2022

replaced by #2111.

@rickstaa rickstaa closed this Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The most used languages only count the oldest 100 projects
4 participants