-
-
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 [Liberapay] #1251
Add [Liberapay] #1251
Conversation
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.
Looks like a good start!
This will need service tests to be merged. Let me know if you have questions about that.
server.js
Outdated
badgeData.colorscheme = 'green'; | ||
} else { | ||
badgeData.colorscheme = '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.
You should be able to accomplish this using colorScale
.
colorScale([0, 10, 100])(receiving)
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'm not sure how to implement that, is there an example somewhere?
server.js
Outdated
sendBadge(format, badgeData); | ||
} | ||
} catch(e) { | ||
badgeData.text[1] = apiUrl; |
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.
Why does this put the API URL on the badge?
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.
That's a testing mistake, looks like I didn't push my latest change.
server.js
Outdated
var data = JSON.parse(buffer); | ||
// Avoid falsey checks because amounts may be 0 | ||
var receiving = data.receiving.amount; | ||
if (!isNaN(receiving)) { |
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.
It's a bit odd to use isNaN
on a JSON value. Can you invert this and test receiving === null
instead?
@paulmelnikow thanks for the early review! |
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.
Thank you for this.
server.js
Outdated
// Avoid falsey checks because amounts may be 0 | ||
if (type == 'gives') { | ||
var value = data.giving.amount; | ||
} else { |
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 there is an indentation problem here. And maybe you could make this part simple with a ternary expression, like: var value = type === 'gives' ? data.giving.amount : data.receiving.amount
.
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.
Yes. Although I may go with a switch since I intend to add more options.
This is an awesome idea/badge. When will it become usable ? |
Hoping to finish it up today or tonight, not sure how long review and deploy will take after that. |
|
Not done yet, tests are weak. |
Looks like a timeout on Travis? Otherwise this is ready for review aside from not knowing the best way to use |
That particular test failure is due to a Shields production issue #1245. We use the Shields server to fetch the PR title from github. |
Is anyone else following this up for writing docs for |
Made changes, don't know if you saw that. |
Hey, thanks for the heads up. Could you find a project you're confident will have patrons and contributions for the foreseeable future? It's okay if we have to switch it to another project down the line. |
It works the same for projects and individuals. Changaco is in charge of Liberapay, so I assumed he would be pretty stable. Or am I misunderstanding the question? |
Ah, I'm referring to this discussion: #1251 (comment) I'd like to change the regex so it rejects 0. It gives more confidence that passing tests == working badge. |
n.b. |
The order of the last push and last commented should be reversed. |
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 looks great. I left couple minor comments. Would love to get this merged!
server.js
Outdated
case 'goal': | ||
badgeData = getBadgeData('goal progress', data); | ||
break; | ||
} |
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.
How about:
const label = {
receives,
gives,
patrons,
goal: 'goal progress',
}[type];
const badgeData = getBadgeData(label, data);
Seems like it would be a good idea to lock down the type
part of the regex to accept only these strings. That way you don't need to handle the errors.
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.
Sounds good. Fixed in 47803f7.
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.
Could you edit the regex too, so it only accepts the four acceptable values?
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.
Weird I didn't see this. Think I fixed in f0a84f7.
service-tests/liberapay.js
Outdated
.get('/patrons/Liberapay.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: 'patrons', | ||
value: Joi.string().regex(/^[1-9]+/) |
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 there any reason not to use isMetric
?
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 don't believe so. Fixed in 66fc147.
Could you address the last pending comment? |
Fabulous! Thanks so much! |
Did I do something wrong? I'm still not seeing this listed at shields.io. |
It's waiting for deploy. Deploys usually happen every 1–3 weeks. Thaddée, who has limited time on this project, is the only sysadmin. He's working on giving me access to deploy and logs, but doing so is complicated because the hosting account (and maybe the servers too) are shared with other services he runs. It's also been held up recently because of #1314. |
Thanks for the explanation. Didn't know how often deployment happened. |
For top-level entities.