-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 [PUB] points badge #7918
add [PUB] points badge #7918
Conversation
This PR depends on #7921. |
services/pub/pub-points.service.js
Outdated
const score = await this.fetch({ packageName }) | ||
const grantedPoints = score.grantedPoints | ||
const maxPoints = score.maxPoints | ||
return this.constructor.render({ grantedPoints, maxPoints, packageName }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is maxPoints
always 130? We seem to be doing a bit of a random mix of using maxPoints
in some places and hard-coding 130
in others..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the maximum number of points for the packages or plugins is 130.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess what I am getting at here is:
- If we expect
maxPoints
can change over time, lets usemaxPoints
as a variable but loosen the validation. If we validate it asJoi.number().min(130).max(130).required()
then ifmaxPoints
ever changes upstream, the badges all break because the validation fails. - If we're saying it can only ever be 130 then its not really buying us anything for it to be a variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so I have made max points dynamic and added nonNegativeInteger validation. So they will not break even if max points change over time.
services/pub/pub-points.service.js
Outdated
return { | ||
label: 'points', | ||
message: `${grantedPoints}/${maxPoints}`, | ||
color: 'brightgreen', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given there is a ceiling on this one, rather than hard-coding the color we can assign a color based on some kind of scale using floorCount()
shields/services/color-formatters.js
Lines 35 to 47 in 9186f0d
function floorCount(value, yellow, yellowgreen, green) { | |
if (value <= 0) { | |
return 'red' | |
} else if (value < yellow) { | |
return 'yellow' | |
} else if (value < yellowgreen) { | |
return 'yellowgreen' | |
} else if (value < green) { | |
return 'green' | |
} else { | |
return 'brightgreen' | |
} | |
} |
shields/services/color-formatters.js
Lines 53 to 55 in 9186f0d
function coveragePercentage(percentage) { | |
return floorCount(percentage, 80, 90, 100) | |
} |
Is there any kind of community norm around what is considered a "good" score we could lean on here? We shouldn't make them all
brightgreen
even if the score is like 4/130 or whatever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I have added the blue color for pub points as there are no such norms for points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this one it seems like the scale is more esoteric. Clearly bigger numbers are better, but is 20 "Documentation" points and 0 "Platform Support" points exactly the same as 10 "Documentation" points and 10 "Platform Support" points. Maybe lets leave this one as blue/informational.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made some changes and assigned colors based on the percentage of their granted points and max points. i.e.
floorCount((grantedPoints / maxPoints) * 100, 40, 60, 80)
Cheers for working on these |
Thanks for your cooperation. |
PUB
to show the points forDart/Flutter
packages and plugins.