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 [Liberapay] #1251

Merged
merged 27 commits into from
Dec 6, 2017
Merged

Add [Liberapay] #1251

merged 27 commits into from
Dec 6, 2017

Conversation

mattbk
Copy link
Contributor

@mattbk mattbk commented Nov 7, 2017

For top-level entities.

Copy link
Member

@paulmelnikow paulmelnikow left a 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';
}
Copy link
Member

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)

Copy link
Contributor Author

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;
Copy link
Member

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?

Copy link
Contributor Author

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)) {
Copy link
Member

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 paulmelnikow added the service-badge Accepted and actionable changes, features, and bugs label Nov 7, 2017
@mattbk
Copy link
Contributor Author

mattbk commented Nov 7, 2017

@paulmelnikow thanks for the early review!

Copy link

@elegaanz elegaanz left a 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 {
Copy link

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.

Copy link
Contributor Author

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.

@mattbk
Copy link
Contributor Author

mattbk commented Nov 8, 2017

Currently:
screen shot 2017-11-07 at 11 58 40 pm

@ghost
Copy link

ghost commented Nov 8, 2017

This is an awesome idea/badge. When will it become usable ?

@mattbk
Copy link
Contributor Author

mattbk commented Nov 8, 2017

Hoping to finish it up today or tonight, not sure how long review and deploy will take after that.

@mattbk
Copy link
Contributor Author

mattbk commented Nov 8, 2017

/home/travis/build/badges/shields/server.js
1073:22 error Missing semicolon semi
1081:15 error 'badgeData' is already defined no-redeclare
1084:15 error 'badgeData' is already defined no-redeclare
1087:15 error 'badgeData' is already defined no-redeclare
1104:67 error Unnecessary escape character: / no-useless-escape
1107:17 error 'value' is already defined no-redeclare
1111:17 error 'value' is already defined no-redeclare
1115:17 error 'value' is already defined no-redeclare
1116:17 error 'currency' is already defined no-redeclare

@mattbk
Copy link
Contributor Author

mattbk commented Nov 8, 2017

Not done yet, tests are weak.

@mattbk
Copy link
Contributor Author

mattbk commented Nov 9, 2017

Looks like a timeout on Travis? Otherwise this is ready for review aside from not knowing the best way to use colorScale().

@paulmelnikow paulmelnikow changed the title WIP: Add Liberapay WIP: Add [Liberapay] Nov 9, 2017
@paulmelnikow
Copy link
Member

PR: badges/shields#1251
Error: 522 Origin Connection Time-out
    at Error (native)
    at fetch.then.res (/home/travis/build/badges/shields/service-tests/runner/pull-request-services-cli.js:27:15)
    at process._tickCallback (internal/process/next_tick.js:109:7)

That particular test failure is due to a Shields production issue #1245. We use the Shields server to fetch the PR title from github.

@paulmelnikow
Copy link
Member

Is anyone else following this up for writing docs for colorScale? There are three good examples to generalize from, in lib/color-formatters.spec.js.

@mattbk mattbk changed the title WIP: Add [Liberapay] Add [Liberapay] Nov 10, 2017
@mattbk
Copy link
Contributor Author

mattbk commented Nov 15, 2017

Made changes, don't know if you saw that.

@paulmelnikow
Copy link
Member

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.

@mattbk
Copy link
Contributor Author

mattbk commented Nov 19, 2017

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?

@paulmelnikow
Copy link
Member

Ah, I'm referring to this discussion:

#1251 (comment)
#1251 (comment)

I'd like to change the regex so it rejects 0. It gives more confidence that passing tests == working badge.

@mattbk
Copy link
Contributor Author

mattbk commented Nov 20, 2017

n.b. npm run test:services -- --only-travis --only=liberapay

@mattbk
Copy link
Contributor Author

mattbk commented Nov 20, 2017

image
This tested with an account with zero patrons and 0.00 receiving. Will now push corrected version.

@mattbk
Copy link
Contributor Author

mattbk commented Nov 20, 2017

The order of the last push and last commented should be reversed.

Copy link
Member

@paulmelnikow paulmelnikow left a 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;
}
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

.get('/patrons/Liberapay.json')
.expectJSONTypes(Joi.object().keys({
name: 'patrons',
value: Joi.string().regex(/^[1-9]+/)
Copy link
Member

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?

Copy link
Contributor Author

@mattbk mattbk Dec 1, 2017

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.

@paulmelnikow
Copy link
Member

Could you address the last pending comment?

#1251 (comment)

@paulmelnikow paulmelnikow merged commit 2028251 into badges:master Dec 6, 2017
@paulmelnikow
Copy link
Member

Fabulous! Thanks so much!

@mattbk
Copy link
Contributor Author

mattbk commented Dec 22, 2017

Did I do something wrong? I'm still not seeing this listed at shields.io.

@paulmelnikow
Copy link
Member

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.

@mattbk
Copy link
Contributor Author

mattbk commented Dec 22, 2017

Thanks for the explanation. Didn't know how often deployment happened.

@mattbk mattbk deleted the add-liberapay branch December 22, 2017 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants