From 81cf9401609807aa17952d524d021b677a6e3810 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Fri, 8 Jan 2021 11:22:31 +0700 Subject: [PATCH] feat: added audios count to uploads stats As always, this uses hardcoded whitelisted audio extensions (the ones that are also internally used for "is:audio" filter). --- controllers/utilsController.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 9a2dcfd..5cda505 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -757,6 +757,7 @@ self.stats = async (req, res, next) => { Total: 0, Images: 0, Videos: 0, + Audios: 0, Others: 0, Temporary: 0, 'Size in DB': { @@ -792,6 +793,16 @@ self.stats = async (req, res, next) => { .count('id as count') .then(rows => rows[0].count) })(), + (async () => { + stats[data.title].Audios = await db.table('files') + .where(function () { + for (const ext of self.audioExts) { + this.orWhere('name', 'like', `%${ext}`) + } + }) + .count('id as count') + .then(rows => rows[0].count) + })(), (async () => { stats[data.title].Temporary = await db.table('files') .whereNotNull('expirydate') @@ -800,7 +811,10 @@ self.stats = async (req, res, next) => { })() ]) - stats[data.title].Others = stats[data.title].Total - stats[data.title].Images - stats[data.title].Videos + stats[data.title].Others = stats[data.title].Total - + stats[data.title].Images - + stats[data.title].Videos - + stats[data.title].Audios // Update cache data.cache = stats[data.title]