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

Total downloads does not count all releases #6766

Open
liamg opened this issue Jul 14, 2021 · 3 comments
Open

Total downloads does not count all releases #6766

liamg opened this issue Jul 14, 2021 · 3 comments
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge

Comments

@liamg
Copy link

liamg commented Jul 14, 2021

Are you experiencing an issue with...

shields.io

🐞 Description

The number in the total downloads badge for our repo has been fluctuating lately. We believe the issue is the badge is only counting downloads for the most recent 500 releases, instead of paging over all API result pages for every release.

🔗 Link to the badge

https://img.shields.io/github/downloads/aquasecurity/tfsec/total

💡 Possible Solution

Iterate over each page of the GitHub API call results using per_page=1000 and page=N.

I think the issue is here:

const allReleases = await this._requestJson({
schema: releaseArraySchema,
url: `/repos/${user}/${repo}/releases`,
options: { qs: { per_page: 500 } },
errorMessages: errorMessagesFor('repo not found'),
})

@liamg liamg added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Jul 14, 2021
liamg added a commit to aquasecurity/tfsec that referenced this issue Jul 14, 2021
Removing badge until badges/shields#6766 is fixed.
owenrumney pushed a commit to aquasecurity/tfsec that referenced this issue Jul 14, 2021
@chris48s
Copy link
Member

I think the max value for per_page on this endpoint is 100, not 1000 (or 500)

https://api.github.com/repos/aquasecurity/tfsec/releases?per_page=500

returns the first 100 items

@chris48s chris48s added bug Bugs in badges and the frontend service-badge New or updated service badge and removed question Support questions, usage questions, unconfirmed bugs, discussions, ideas labels Jul 14, 2021
@calebcartwright
Copy link
Member

I'm not sure how common this will be in practice, but we may need something similar to the approach we had to take for the Docker badges of firing off the requests for the pages in parallel. If we have to go through the 5+ page sequence synchronously then I wouldn't be surprised if we run into timeout issues

@calebcartwright
Copy link
Member

The other challenge is that while we could theoretically have a max ceiling of two sequential calls with the v3 API (since we can calculate the calls for each page and fire them in parallel). However, I'm not sure the same is viable with graphql, as the latter will require us to actually iterate through each page one by one. This is unfortunate as it's tough to rationalize increased investment in v3 at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge
Projects
None yet
Development

No branches or pull requests

3 participants