Skip to content

Commit

Permalink
download_count.js now also shows per release
Browse files Browse the repository at this point in the history
  • Loading branch information
0neGal committed Feb 4, 2024
1 parent cfca7b5 commit 24b372b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions scripts/download_count.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ const https = require("https");

let link = "/repos/0neGal/viper/releases";

let count = 0;
let releases = {};
let total_count = 0;

let parse_release = (release) => {
let assets = release.assets;
let name = release.name + ":";

for (let i = 0; i < assets.length; i++) {
// dont count blockmaps
if (assets[i].name.match("blockmap")) {
Expand All @@ -17,8 +20,20 @@ let parse_release = (release) => {
case "latest.yml":
case "latest-linux.yml":
continue;

default:
count += assets[i].download_count;
let downloads = assets[i].download_count;

if (! releases[name]) {
releases[name] = 0;
}

total_count += downloads;
releases[name] += downloads;
}

if (i == assets.length - 1) {
console.log(name, releases[name]);
}
}
}
Expand All @@ -29,7 +44,8 @@ let parse_json = (json) => {
parse_release(json[i]);
}

console.log("Download count:", count);
console.log();
console.log("Total download count:", total_count);
}

https.get({
Expand Down

0 comments on commit 24b372b

Please sign in to comment.