Skip to content

Commit

Permalink
Get latest GitHub release by creation dates comparison
Browse files Browse the repository at this point in the history
Fixes #169
  • Loading branch information
LeoColomb committed May 4, 2014
1 parent f477e1a commit a5851b5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,17 @@ cache(function(data, match, sendBadge) {
try {
var data = JSON.parse(buffer);
var latest = (function () {
for (var i = 0, len = data.length; i < len; i++) {
if (!data[i].draft) {
return data[i];
}
var topTag, tagDate, topDate = null;
for (var i = 0, len = data.length; i < len; i++) {
if (!data[i].draft) {
tagDate = new Date(data[i].created_at);
if (topDate === null || tagDate > topDate) {
topDate = tagDate;
topTag = i;
}
}
}
return data[topTag];
})();
var tag = latest.tag_name;
badgeData.text[1] = tag;
Expand Down

0 comments on commit a5851b5

Please sign in to comment.