docs: fix the downloads badge, which was rate limited and off-colour - #58
Merged
Merged
Conversation
The profile badge row rendered "downloads | rate limited by upstream service" instead of a number. shields.io's pypi/dm endpoint reads pypistats on demand and is throttled, so the badge fails in exactly the place it is seen most. pepy.tech serves a pre-rendered badge and is what commit-check's own README already uses (README.md:6), down to the same brand blue, so this is the pattern the project had already settled on rather than a new dependency. The link follows the badge to the pepy project page, as it does there. The colour is spelled `%232c9ccd` because pepy takes a literal CSS colour and the `#` has to survive the query string; shields.io accepted a bare `2c9ccd`, which is why the two looked different. Verified against commit-check/README.md rather than by fetching: static.pepy.tech is refused by this sandbox's egress proxy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6
|
Warning Review limit reachedNext included review available in 32 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Commit Check✅ All 4 checks passed Show all 4 checkscommit-check 2.15.0 · Rules reference |
The previous commit in this branch moved the badge to pepy's own renderer
and carried the `?color=%232c9ccd` that commit-check's README uses. The
badge came back the right number and the wrong blue, visibly off from the
four shields.io badges beside it.
pepy's source says why. `/badge/<project>/month` is served by
`generate_last_30_days_badge`, which calls the badge builder with
`right_color="blue"` hardcoded and reads no colour from the query string
at all:
s = badge(left_text="downloads/month", right_text=downloads,
right_color="blue")
Colour is only configurable on pepy's separate `personalized-badge`
endpoint, which takes `left_color`/`right_color`. `?color=` has never
done anything on either. The same dead parameter is in
commit-check/README.md:6, where the badge is also rendering pepy's
default blue rather than the brand colour.
So the badge now goes through shields.io's own Pepy endpoint --
`/pepy/dt/:packageName`, per services/pepy/pepy-downloads.service.js --
which keeps pepy as the data source but hands the drawing to the same
renderer as the PyPI, Marketplace, License and Website badges on the row.
The colour cannot drift from theirs because it is the same code and the
same `2c9ccd`, spelled the way they spell it, without the `%23` pepy
would have needed.
Two consequences worth knowing. The number is now total downloads rather
than the last thirty days, because that route has no period parameter.
And it does not inherit the throttling this branch set out to fix:
shields.io queries api.pepy.tech with its own API key and caches for
eight hours, rather than reading pypistats on demand the way the original
img.shields.io/pypi/dm badge did.
Neither badge could be rendered here to compare -- the egress proxy
refuses static.pepy.tech, img.shields.io and shields.io alike -- so this
rests on the two services' source rather than on a screenshot.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6
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.
The downloads badge on the org profile rendered
downloads | rate limited by upstream serviceinstead of a number, in the first screenful of the profile, next to four badges that work.img.shields.io/pypi/dmreads pypistats on demand and gets throttled.img.shields.io/pepy/dttakes its number from pepy instead — shields.io callsapi.pepy.techwith its own API key and caches for eight hours, so it is not exposed to the throttling that broke the old badge.Why not pepy's own badge
The first commit here did the obvious thing and pointed at
static.pepy.tech/badge/commit-check/month?color=%232c9ccd, matching whatcommit-check's README already uses. That came back with the right number and the wrong blue — visibly off from the four shields.io badges beside it.pepy's source explains it.
/badge/<project>/monthis served bygenerate_last_30_days_badge, which hardcodes the colour and reads nothing from the query string (badge_service.py):Colour is only configurable on pepy's separate
personalized-badgeendpoint, which takesleft_color/right_color.?color=has never done anything on that route.Going through shields.io instead means the colour is drawn by the same renderer as the PyPI, Marketplace, License and Website badges on the same row, from the same
2c9ccd— spelled the way they spell it, with no%23. It cannot drift from theirs, because it is the same code.Two things to know
/pepy/dt/:packageName(service definition) has no period parameter. This was a deliberate trade: an exact colour match was worth more than the period.?color=is incommit-check/README.md:6, so that badge is also showing pepy's default blue rather than the brand colour. Not touched here — different repository, and worth a one-line PR of its own.Verification
Neither badge could be rendered here to compare: the egress proxy refuses
static.pepy.tech,img.shields.ioandshields.ioalike. This rests on reading both services' source, not on a screenshot. What is not in doubt is the colour — the four neighbouring badges already prove shields.io renders2c9ccdcorrectly.🤖 Generated with Claude Code
https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6