feat: add total release assets download count via /assets-dl/:owner/:repo/total - #786
Open
gumaciel wants to merge 3 commits into
Open
feat: add total release assets download count via /assets-dl/:owner/:repo/total#786gumaciel wants to merge 3 commits into
gumaciel wants to merge 3 commits into
Conversation
- Adds support for /github/assets-dl/:owner/:repo/total and /all endpoints - Paginates up to 5 pages (500 releases max) to sum download counts across all release assets - Updates documentation and handler example lists
|
@gumaciel is attempting to deploy a commit to the Badgen Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently, the GitHub assets download badge endpoint (
/github/assets-dl/:owner/:repo/:tag?) only supports fetching downloads for the latest release (when tag is omitted) or for a specific release tag (e.g./v7.0.0).Users who want to display the total asset download count across recent releases cannot do so.
Solution
Add support for
/github/assets-dl/:owner/:repo/total(and/all) to calculate total asset downloads for recent releases.GET /repos/{owner}/{repo}/releases?per_page=30.download_countfor all assets found across the returned releases.millify()and returns a green badge (or grey'no releases'if none exist).pages/api/github.tsandpublic/badges.md.Implementation Notes & Trade-offs
per_pageto100fetches more releases, heavy repositories with many binary assets per release (likeelectron/electron) generate large JSON responses that triggerRequestError: Timeout awaiting 'request' for 6400msconfigured inlibs/got.ts.per_page=30): Querying the 30 most recent releases proved to be the safest and most reliable threshold during testing across various repositories.Usage