mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +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')
|
await db.table('files')
|
||||||
.whereIn('id', files.map(file => file.id))
|
.whereIn('id', files.map(file => file.id))
|
||||||
.update('albumid', albumid)
|
.update('albumid', albumid)
|
||||||
|
utils.invalidateStatsCache('albums')
|
||||||
|
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
if (file.albumid && !albumids.includes(file.albumid)) {
|
if (file.albumid && !albumids.includes(file.albumid)) {
|
||||||
|
@ -874,16 +874,24 @@ self.stats = async (req, res, next) => {
|
|||||||
|
|
||||||
const albums = await db.table('albums')
|
const albums = await db.table('albums')
|
||||||
stats[data.title].Total = albums.length
|
stats[data.title].Total = albums.length
|
||||||
|
|
||||||
|
const activeAlbums = []
|
||||||
for (const album of albums) {
|
for (const album of albums) {
|
||||||
if (!album.enabled) {
|
if (!album.enabled) {
|
||||||
stats[data.title].Disabled++
|
stats[data.title].Disabled++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
activeAlbums.push(album.id)
|
||||||
if (album.download) stats[data.title].Downloadable++
|
if (album.download) stats[data.title].Downloadable++
|
||||||
if (album.public) stats[data.title].Public++
|
if (album.public) stats[data.title].Public++
|
||||||
if (album.zipGeneratedAt) stats[data.title]['ZIP Generated']++
|
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
|
// Update cache
|
||||||
data.cache = stats[data.title]
|
data.cache = stats[data.title]
|
||||||
data.generating = false
|
data.generating = false
|
||||||
|
Loading…
Reference in New Issue
Block a user