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).
This commit is contained in:
Bobby Wibowo 2021-01-08 11:22:31 +07:00
parent 991d743ef0
commit 81cf940160
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -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]