badges / badges/shields

Add max, min, and sum functions for dynamic badges

Open
#6,071 6 comments 3 reactions 0 assignees View on GitHub
needs-upstream-help question
Dominant language
JavaScript
Stars
27.2k
Forks
5.6k
Avg merge
1d 8h
Merged PRs (30d)
46

Description

Are you experiencing an issue with...

- [x] [shields.io](https://shields.io/#/)
- [ ] My own instance
- [ ] [badge-maker NPM package](https://www.npmjs.com/package/badge-maker)

:beetle: **Description**

`.max()`, `.sum()`, `.min()` functions in dynamic badge queries don't work.

Support for `.max()`, `.sum()`, `.min()` would be a great help and improve the flexibility of dynamic badges.

Examples:`$.numbers.sum()`, `$.numbers.min()`, `$.numbers.max()`, `$.sum($.numbers.max())`

:link: **Example badges**

Doesn't work when `.sum()` is present: ![Failing Badge](https://img.shields.io/badge/dynamic/json?label=commits&query=%24..contributions.sum%28%29&url=https%3A%2F%2Fapi.github.com%2Frepos%2FYashTotale%2FYashTotale.github.io%2Fcontributors)

Works when `.sum()` is not present: ![Working Badge](https://img.shields.io/badge/dynamic/json?label=commits&query=%24..contributions&url=https%3A%2F%2Fapi.github.com%2Frepos%2FYashTotale%2FYashTotale.github.io%2Fcontributors)

:bulb: **Possible Solution**

I think this is a problem with the upstream `jsonpath` library, and I have filed an [issue](https://github.com/dchester/jsonpath/issues/153) in that repo as well. I thought informing the maintainers of this project as well would be a good idea.

Thanks!

Contributor guide

Open the contributing guide

Research direction

Reproduce the failing dynamic JSON badge URL and compare it with the working URL. Then inspect the dynamic badge query path and its upstream jsonpath dependency, using the listed $.numbers and $.sum examples as acceptance cases; done means max, min, and sum queries work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.