-
-
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
[github] download count for latest pre-release #1140
Conversation
#1118 really helped me with developing this change. |
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.
Thanks a bunch! I left a couple minor comments.
server.js
Outdated
badgeData.text[1] = metric(downloads); | ||
if (label) { | ||
badgeData.text[1] += ' ' + label; | ||
} |
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.
This code could be made clearer using Array.prototype.join
:
const labelWords = [metric(downloads)];
if (tag !== latest) {
labelWords.push(tag);
}
if (asset_name !== 'total') {
labelWords.push(`[${asset_name}]`);
}
badgeData.text[1] = labelWords.join(' ');
This might avoid future bugs too!
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.
Great idea! Thanks.
service-tests/github.js
Outdated
.get('/downloads-pre/photonstorm/phaser/latest/total.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: Joi.equal('downloads'), | ||
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]?$/) |
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.
Hopefully I will merge #1127 in a moment. Could you DRY this up by using isMetric
?
- `isMetric` tests must be > 0 to pass. - Fix downloads badge bug introduced in #1140. (So much for [being clever](#1140 (comment))!) - Fix 1 week activity badge by returning the previous week instead of the current week.
PRs like this are the reason I'd argue that it's generally advisable to use GitHub's "squash and merge" option rather than the standard merge. |
I think I agree, though this was merged using "squash and merge." |
My bad, you're right, sorry. |
Implements #1113.
Additionally I've removed extra space in 2 cases (failing tests without this change):