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

Add a render helper for downloads badges, run [amo ansible apm chromewebstore clojars conda crates docker dub eclipse gem githubdownloads] #7163

Merged
merged 4 commits into from
Oct 26, 2021

Conversation

calebcartwright
Copy link
Member

We've got a quite a large number of download count related badges, and as I'm sure folks can imagine (and see in the diff), we've got a good deal of duplication around rendering concerns because we don't have a rendering helper like we do for others (e.g. version badges). In my opinion there's a lot of opportunity for encapsulation and reuse, both with our existing badges and to make things simpler for any future such badges

This PR both creates the render helper for download count badges, and includes the updates to the first batch of service classes to take advantage. Once the PR review app is up I'll post a comment that includes before/after badges between the review app and what we do today as an additional step to ensure there's no changes introduced.

@calebcartwright calebcartwright added the service-badge New or updated service badge label Oct 16, 2021
@shields-cd shields-cd temporarily deployed to shields-staging-pr-7163 October 16, 2021 21:35 Inactive
@shields-ci
Copy link

shields-ci commented Oct 16, 2021

Warnings
⚠️ This PR modified service code for github but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for gem but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for eclipse-marketplace but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for dub but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for docker but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for crates but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for conda but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for clojars but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for chrome-web-store but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for apm but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for ansible but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for amo but not its test code.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @calebcartwright!

Generated by 🚫 dangerJS against cc39d75

@calebcartwright
Copy link
Member Author

calebcartwright commented Oct 17, 2021

AMO

https://shields-staging-pr-7163.herokuapp.com/amo/dw/dustman

https://img.shields.io/amo/dw/dustman

https://shields-staging-pr-7163.herokuapp.com/amo/dw/caleb-is-not-real

https://img.shields.io/amo/dw/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/amo/users/dustman

https://img.shields.io/amo/users/dustman

https://shields-staging-pr-7163.herokuapp.com/amo/users/caleb-is-not-real

https://img.shields.io/amo/users/caleb-is-not-real

Ansible

https://shields-staging-pr-7163.herokuapp.com/ansible/role/d/3078

https://img.shields.io/ansible/role/d/3078

https://shields-staging-pr-7163.herokuapp.com/ansible/role/d/caleb-is-not-real

https://img.shields.io/ansible/role/d/caleb-is-not-real

APM

https://shields-staging-pr-7163.herokuapp.com/apm/dm/vim-mode

https://img.shields.io/apm/dm/vim-mode

https://shields-staging-pr-7163.herokuapp.com/apm/dm/caleb-is-not-real

https://img.shields.io/apm/dm/caleb-is-not-real

Chrome Web Store

https://shields-staging-pr-7163.herokuapp.com/chrome-web-store/users/ogffaloegjglncjfehdfplabnoondfjo

https://img.shields.io/chrome-web-store/users/ogffaloegjglncjfehdfplabnoondfjo

https://shields-staging-pr-7163.herokuapp.com/chrome-web-store/users/caleb-is-not-real

https://img.shields.io/chrome-web-store/users/caleb-is-not-real

Clojars

https://shields-staging-pr-7163.herokuapp.com/clojars/dt/prismic

https://img.shields.io/clojars/dt/prismic

https://shields-staging-pr-7163.herokuapp.com/clojars/dt/caleb-is-not-real

https://img.shields.io/clojars/dt/caleb-is-not-real

Conda

https://shields-staging-pr-7163.herokuapp.com/conda/dn/conda-forge/python

https://img.shields.io/conda/dn/conda-forge/python

https://shields-staging-pr-7163.herokuapp.com/conda/d/conda-forge/python

https://img.shields.io/conda/d/conda-forge/python

https://shields-staging-pr-7163.herokuapp.com/conda/dn/conda-forge/caleb-is-not-real

https://img.shields.io/conda/dn/conda-forge/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/conda/d/conda-forge/caleb-is-not-real

https://img.shields.io/conda/d/conda-forge/caleb-is-not-real

Crates.io

https://shields-staging-pr-7163.herokuapp.com/crates/d/ripgrep

https://img.shields.io/crates/d/ripgrep

https://shields-staging-pr-7163.herokuapp.com/crates/dv/ripgrep

https://img.shields.io/crates/dv/ripgrep

https://shields-staging-pr-7163.herokuapp.com/crates/dv/ripgrep/12.1.1

https://img.shields.io/crates/dv/ripgrep/12.1.1

https://shields-staging-pr-7163.herokuapp.com/crates/dr/ripgrep

https://img.shields.io/crates/dr/ripgrep

https://shields-staging-pr-7163.herokuapp.com/crates/d/caleb-is-not-real

https://img.shields.io/crates/d/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/crates/dv/caleb-is-not-real

https://img.shields.io/crates/dv/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/crates/dv/caleb-is-not-real/12.1.1

https://img.shields.io/crates/dv/caleb-is-not-real/12.1.1

https://shields-staging-pr-7163.herokuapp.com/crates/dv/ripgrep/100.99.98

https://img.shields.io/crates/dv/ripgrep/100.99.98

https://shields-staging-pr-7163.herokuapp.com/crates/dr/caleb-is-not-real

https://img.shields.io/crates/dr/caleb-is-not-real

Docker

https://shields-staging-pr-7163.herokuapp.com/docker/pulls/_/ubuntu

https://img.shields.io/docker/pulls/_/ubuntu

https://shields-staging-pr-7163.herokuapp.com/docker/pulls/_/caleb-is-not-real

https://img.shields.io/docker/pulls/_/caleb-is-not-real

Dub

https://shields-staging-pr-7163.herokuapp.com/dub/dd/vibe-d

https://img.shields.io/dub/dd/vibe-d

https://shields-staging-pr-7163.herokuapp.com/dub/dd/dub/1.16.0

https://img.shields.io/dub/dd/dub/1.16.0

https://shields-staging-pr-7163.herokuapp.com/dub/dw/vibe-d

https://img.shields.io/dub/dw/vibe-d

https://shields-staging-pr-7163.herokuapp.com/dub/dw/vibe-d/0.9.4

https://img.shields.io/dub/dw/vibe-d/0.9.4

https://shields-staging-pr-7163.herokuapp.com/dub/dm/vibe-d

https://img.shields.io/dub/dm/vibe-d

https://shields-staging-pr-7163.herokuapp.com/dub/dm/vibe-d/0.9.4

https://img.shields.io/dub/dm/vibe-d/0.9.4

https://shields-staging-pr-7163.herokuapp.com/dub/dt/vibe-d

https://img.shields.io/dub/dt/vibe-d

https://shields-staging-pr-7163.herokuapp.com/dub/dt/vibe-d/0.9.4

https://img.shields.io/dub/dt/vibe-d/0.9.4

https://shields-staging-pr-7163.herokuapp.com/dub/dd/caleb-is-not-real

https://img.shields.io/dub/dd/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/dub/dd/caleb-is-not-real/1.16.0

https://img.shields.io/dub/dd/caleb-is-not-real/1.16.0

https://shields-staging-pr-7163.herokuapp.com/dub/dw/caleb-is-not-real

https://img.shields.io/dub/dw/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/dub/dw/caleb-is-not-real/0.9.4

https://img.shields.io/dub/dw/caleb-is-not-real/0.9.4

https://shields-staging-pr-7163.herokuapp.com/dub/dm/caleb-is-not-real

https://img.shields.io/dub/dm/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/dub/dm/caleb-is-not-real/0.9.4

https://img.shields.io/dub/dm/caleb-is-not-real/0.9.4

https://shields-staging-pr-7163.herokuapp.com/dub/dt/caleb-is-not-real

https://img.shields.io/dub/dt/caleb-is-not-real

https://shields-staging-pr-7163.herokuapp.com/dub/dt/caleb-is-not-real/0.9.4

https://img.shields.io/dub/dt/caleb-is-not-real/0.9.4

Comment on lines +4 to +11
function renderDownloadsBadge({
downloads,
interval,
version,
labelOverride,
colorOverride,
messageSuffixOverride,
}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this helper is a good example of a function that would benefit from a docstring comment explaining what each of these 6 params does, which ones are required/optional, etc as it is a bit more complex than something like renderLicenseBadge or renderVersionBadge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, and there's not actually any input validation in here currently. Do you think it'd be worthwhile to add some? E.g. ensure downloads is provided and numerical (or at least numerically coercible)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah its a good question that I don't have a completely solid answer to.

Just looking over renderVersionBadge, renderLicenseBadge, renderBuildStatusBadge they're a bit of a mixed bag.
I reckon its mostly fine to delegate responsibility for passing sensible values to renderDownloadsBadge to the service layer. My instinct is that at this layer of the application we probably don't want to be throwing a lot of exceptions that we need to remember to catch in the service layer but we probably do have some formatting helpers that do throw under some circumstances. Maybe we should be aiming to guard against outputting stuff like message: '12k/undefined' though.

Dunno how much help that is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented in 3eda04b. I couldn't quite convince myself to add any input validation and exception throwing so have opted to leave that possibility for a future day should the need arise

@shields-cd shields-cd temporarily deployed to shields-staging-pr-7163 October 23, 2021 15:19 Inactive
@calebcartwright calebcartwright temporarily deployed to shields-staging-pr-7163 October 23, 2021 18:46 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants