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

[hhvm] #1499 - update hhvm service #1508

Merged
merged 9 commits into from
Feb 19, 2018
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,12 +1300,9 @@ cache(function(data, match, sendBadge, request) {
var user = match[1]; // eg, `symfony/symfony`.
var branch = match[2];// eg, `/2.4.0.0`.
var format = match[3];
var apiUrl = 'http://hhvm.h4cc.de/badge/' + user + '.json';
if (branch) {
// Remove the leading slash.
apiUrl += '?branch=' + branch.slice(1);
}
var apiUrl = 'https://php-eye.com/api/v1/package/'+user+'.json';
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 update the variable declarations to use the ES6 style let and const as applicable while you're working on this code.

var badgeData = getBadgeData('hhvm', data);
branch = branch || 'dev-master';
request(apiUrl, function dealWithData(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
Expand All @@ -1314,18 +1311,33 @@ cache(function(data, match, sendBadge, request) {
}
try {
var data = JSON.parse(buffer);
var status = data.hhvm_status;
if (status === 'not_tested') {
badgeData.colorscheme = 'red';
badgeData.text[1] = 'not tested';
} else if (status === 'partial') {
badgeData.colorscheme = 'yellow';
badgeData.text[1] = 'partially tested';
} else if (status === 'tested') {
badgeData.colorscheme = 'brightgreen';
badgeData.text[1] = 'tested';
} else {
badgeData.text[1] = 'maybe untested';
var verInfo = {};
for (var i = 0, count = data.versions.length; i < count; i++) {
verInfo = data.versions[i];
if (verInfo.name == branch) {
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 use a strict comparison here please (triple equals)

switch (verInfo.travis.hhvm) {
case 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch statement would be easier to read if the cases were indented by a block (sorry to leave feedback on indenting :( this should really be picked up by a linting rule!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do (I copy/pasted a switch statement from elsewhere in the code)

// unknown/no config file
badgeData.text[1] = 'maybe untested';
break;
case 1:
// not tested
badgeData.colorscheme = 'red';
badgeData.text[1] = 'not tested';
break;
case 2:
// allowed failure
badgeData.colorscheme = 'yellow';
badgeData.text[1] = 'partially tested';
break;
case 3:
// tested`
badgeData.colorscheme = 'brightgreen';
badgeData.text[1] = 'tested';
break;
}
break;
}
}
sendBadge(format, badgeData);
} catch(e) {
Expand Down