Skip to content

Instantly share code, notes, and snippets.

@comountainclimber
Created January 31, 2020 05:12
Show Gist options
  • Save comountainclimber/1a2fe1e3d4f70468177dfbf73ebf7950 to your computer and use it in GitHub Desktop.
Save comountainclimber/1a2fe1e3d4f70468177dfbf73ebf7950 to your computer and use it in GitHub Desktop.
Print Neon Wallet download count to console (node)
const https = require("https");
const options = {
headers: {
"User-Agent": "comountainclimber"
}
};
https.get(
"https://api.github.com/repos/CityOfZion/neon-wallet/releases",
options,
res => {
res.setEncoding("utf8");
let rawData = "";
res.on("data", chunk => {
rawData += chunk;
});
res.on("end", () => {
const releases = JSON.parse(rawData);
let totalCount = 0;
let releaseCountSince2 = 0;
const countPerRelease = {};
releases.forEach(release => {
let releaseTotal = 0;
const countForRelease = release.assets.forEach(asset => {
const { download_count } = asset;
console.log(download_count);
totalCount += download_count;
releaseTotal += download_count;
if (release.tag_name[0] === "2") {
releaseCountSince2 += download_count;
}
});
countPerRelease[release.tag_name] = releaseTotal;
});
console.log({
totalCount,
countPerRelease,
releaseCountSince2
});
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment