mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
feat: add "files in albums" to albums stats
This commit is contained in:
parent
defa3f2a8c
commit
991d743ef0
@ -626,6 +626,7 @@ self.addFiles = async (req, res, next) => {
|
||||
await db.table('files')
|
||||
.whereIn('id', files.map(file => file.id))
|
||||
.update('albumid', albumid)
|
||||
utils.invalidateStatsCache('albums')
|
||||
|
||||
files.forEach(file => {
|
||||
if (file.albumid && !albumids.includes(file.albumid)) {
|
||||
|
@ -874,16 +874,24 @@ self.stats = async (req, res, next) => {
|
||||
|
||||
const albums = await db.table('albums')
|
||||
stats[data.title].Total = albums.length
|
||||
|
||||
const activeAlbums = []
|
||||
for (const album of albums) {
|
||||
if (!album.enabled) {
|
||||
stats[data.title].Disabled++
|
||||
continue
|
||||
}
|
||||
activeAlbums.push(album.id)
|
||||
if (album.download) stats[data.title].Downloadable++
|
||||
if (album.public) stats[data.title].Public++
|
||||
if (album.zipGeneratedAt) stats[data.title]['ZIP Generated']++
|
||||
}
|
||||
|
||||
stats[data.title]['Files in albums'] = await db.table('files')
|
||||
.whereIn('albumid', activeAlbums)
|
||||
.count('id as count')
|
||||
.then(rows => rows[0].count)
|
||||
|
||||
// Update cache
|
||||
data.cache = stats[data.title]
|
||||
data.generating = false
|
||||
|
Loading…
Reference in New Issue
Block a user