diff options
author | 0neGal <mail@0negal.com> | 2024-02-05 00:22:13 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-02-05 00:22:13 +0100 |
commit | 24b372bc3196eae361f6235c912541b9dfe1aab3 (patch) | |
tree | dc05ebbb5ebdf77f9a5920aa6000f77926605d8c | |
parent | cfca7b565e2ea6f7acaad42a92f7671e4c4ab9fc (diff) | |
download | Viper-24b372bc3196eae361f6235c912541b9dfe1aab3.tar.gz Viper-24b372bc3196eae361f6235c912541b9dfe1aab3.zip |
download_count.js now also shows per release
-rw-r--r-- | scripts/download_count.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/download_count.js b/scripts/download_count.js index dc8fe32..47dae4b 100644 --- a/scripts/download_count.js +++ b/scripts/download_count.js @@ -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")) { @@ -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]); } } } @@ -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({ |