Skip to content

Instantly share code, notes, and snippets.

@mcliment
Created February 18, 2016 12:33
Show Gist options
  • Save mcliment/005f80a0be4d1457a186 to your computer and use it in GitHub Desktop.
Save mcliment/005f80a0be4d1457a186 to your computer and use it in GitHub Desktop.
Waiting for ASP.NET Core RC2
var http = require("https");
var openUrl = "/search/issues?q=user:aspnet+is:open+milestone:1.0.0-rc2";
var closedUrl = "/search/issues?q=user:aspnet+is:closed+milestone:1.0.0-rc2";
function getCount(url) {
return new Promise((resolve, reject) => {
var req = http.request({
hostname: "api.github.com",
path: url,
headers: { "User-Agent": "nodejs API testing agent" }, // This is required by the API
}, (res) => {
var data = '';
res.on('data', (buffer) => {
data += buffer.toString('utf8');
});
res.on('end', () => {
var info = JSON.parse(data);
resolve(info.total_count);
});
});
req.end();
req.on("error", (e) => {
reject(e);
});
});
}
var popen = getCount(openUrl);
var pclose = getCount(closedUrl);
Promise.all([popen, pclose])
.then((values) => {
var openCount = values[0];
var closedCount = values[1];
var progress = Math.round(closedCount * 100 / (openCount + closedCount));
console.info(`Open: ${openCount}, Closed: ${closedCount}, Progress: ${progress}%`);
})
.catch((reason) => {
console.error(reason);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment