mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-21 11:19:37 +00:00
Merge pull request #1518 from mfcar/addSizeStats
Add largest item stats
This commit is contained in:
commit
5c250da388
12 changed files with 55 additions and 5 deletions
|
|
@ -637,6 +637,7 @@ class LibraryController {
|
|||
var authorsWithCount = libraryHelpers.getAuthorsWithCount(libraryItems)
|
||||
var genresWithCount = libraryHelpers.getGenresWithCount(libraryItems)
|
||||
var durationStats = libraryHelpers.getItemDurationStats(libraryItems)
|
||||
var sizeStats = libraryHelpers.getItemSizeStats(libraryItems)
|
||||
var stats = {
|
||||
totalItems: libraryItems.length,
|
||||
totalAuthors: Object.keys(authorsWithCount).length,
|
||||
|
|
@ -645,6 +646,7 @@ class LibraryController {
|
|||
longestItems: durationStats.longestItems,
|
||||
numAudioTracks: durationStats.numAudioTracks,
|
||||
totalSize: libraryHelpers.getLibraryItemsTotalSize(libraryItems),
|
||||
largestItems: sizeStats.largestItems,
|
||||
authorsWithCount,
|
||||
genresWithCount
|
||||
}
|
||||
|
|
@ -755,4 +757,4 @@ class LibraryController {
|
|||
next()
|
||||
}
|
||||
}
|
||||
module.exports = new LibraryController()
|
||||
module.exports = new LibraryController()
|
||||
|
|
|
|||
|
|
@ -280,6 +280,19 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
|
||||
getItemSizeStats(libraryItems) {
|
||||
var sorted = sort(libraryItems).desc(li => li.media.size)
|
||||
var top10 = sorted.slice(0, 10).map(li => ({ id: li.id, title: li.media.metadata.title, size: li.media.size })).filter(i => i.size > 0)
|
||||
var totalSize = 0
|
||||
libraryItems.forEach((li) => {
|
||||
totalSize += li.media.size
|
||||
})
|
||||
return {
|
||||
totalSize,
|
||||
largestItems: top10
|
||||
}
|
||||
},
|
||||
|
||||
getLibraryItemsTotalSize(libraryItems) {
|
||||
var totalSize = 0
|
||||
libraryItems.forEach((li) => {
|
||||
|
|
@ -843,4 +856,4 @@ module.exports = {
|
|||
|
||||
return Object.values(albums)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue