From 24b372bc3196eae361f6235c912541b9dfe1aab3 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 5 Feb 2024 00:22:13 +0100 Subject: download_count.js now also shows per release --- scripts/download_count.js | 22 +++++++++++++++++++--- 1 file 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({ -- cgit v1.2.3