mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-11 06:19:39 +00:00
New data model fix library stats
This commit is contained in:
parent
57399bb79e
commit
eea3e2583c
8 changed files with 69 additions and 33 deletions
|
|
@ -72,8 +72,12 @@ class Book {
|
|||
|
||||
get size() {
|
||||
var total = 0
|
||||
this.audiobooks.forEach((ab) => total += ab.size)
|
||||
this.ebooks.forEach((eb) => total += eb.size)
|
||||
this.audiobooks.forEach((ab) => {
|
||||
total += ab.size
|
||||
})
|
||||
this.ebooks.forEach((eb) => {
|
||||
total += eb.size
|
||||
})
|
||||
return total
|
||||
}
|
||||
get hasMediaEntities() {
|
||||
|
|
@ -87,6 +91,9 @@ class Book {
|
|||
get hasEmbeddedCoverArt() {
|
||||
return this.audiobooks.some(ab => ab.hasEmbeddedCoverArt)
|
||||
}
|
||||
get hasIssues() {
|
||||
return this.audiobooks.some(ab => ab.missingParts.length)
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
var json = this.toJSON()
|
||||
|
|
@ -293,5 +300,24 @@ class Book {
|
|||
var audiobook = this.getCreateAudiobookVariant(variant)
|
||||
audiobook.audioFiles.push(audioFile)
|
||||
}
|
||||
|
||||
getLongestDuration() {
|
||||
if (!this.audiobooks.length) return 0
|
||||
var longest = 0
|
||||
this.audiobooks.forEach((ab) => {
|
||||
if (ab.duration > longest) longest = ab.duration
|
||||
})
|
||||
return longest
|
||||
}
|
||||
getTotalAudioTracks() {
|
||||
var total = 0
|
||||
this.audiobooks.forEach((ab) => total += ab.tracks.length)
|
||||
return total
|
||||
}
|
||||
getTotalDuration() {
|
||||
var total = 0
|
||||
this.audiobooks.forEach((ab) => total += ab.duration)
|
||||
return total
|
||||
}
|
||||
}
|
||||
module.exports = Book
|
||||
|
|
@ -43,8 +43,7 @@ class Podcast {
|
|||
metadata: this.metadata.toJSON(),
|
||||
coverPath: this.coverPath,
|
||||
tags: [...this.tags],
|
||||
episodes: this.episodes.map(e => e.toJSON()),
|
||||
|
||||
episodes: this.episodes.map(e => e.toJSON())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,19 +53,14 @@ class Podcast {
|
|||
metadata: this.metadata.toJSONExpanded(),
|
||||
coverPath: this.coverPath,
|
||||
tags: [...this.tags],
|
||||
episodes: this.episodes.map(e => e.toJSON()),
|
||||
|
||||
episodes: this.episodes.map(e => e.toJSON())
|
||||
}
|
||||
}
|
||||
|
||||
get tracks() {
|
||||
return []
|
||||
}
|
||||
get duration() {
|
||||
return 0
|
||||
}
|
||||
get size() {
|
||||
return 0
|
||||
var total = 0
|
||||
this.episodes.forEach((ep) => total += ep.size)
|
||||
return total
|
||||
}
|
||||
get hasMediaEntities() {
|
||||
return !!this.episodes.length
|
||||
|
|
@ -77,6 +71,9 @@ class Podcast {
|
|||
get hasEmbeddedCoverArt() {
|
||||
return false
|
||||
}
|
||||
get hasIssues() {
|
||||
return false
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
var json = this.toJSON()
|
||||
|
|
@ -105,10 +102,6 @@ class Podcast {
|
|||
return true
|
||||
}
|
||||
|
||||
checkUpdateMissingTracks() {
|
||||
return false
|
||||
}
|
||||
|
||||
removeFileWithInode(inode) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -138,5 +131,23 @@ class Podcast {
|
|||
var payload = this.metadata.searchQuery(query)
|
||||
return payload || {}
|
||||
}
|
||||
|
||||
getLongestDuration() {
|
||||
if (!this.episodes.length) return 0
|
||||
var longest = 0
|
||||
this.episodes.forEach((ab) => {
|
||||
if (ab.duration > longest) longest = ab.duration
|
||||
})
|
||||
return longest
|
||||
}
|
||||
|
||||
getTotalAudioTracks() {
|
||||
return this.episodes.length
|
||||
}
|
||||
getTotalDuration() {
|
||||
var total = 0
|
||||
this.episodes.forEach((ep) => total += ep.duration)
|
||||
return total
|
||||
}
|
||||
}
|
||||
module.exports = Podcast
|
||||
Loading…
Add table
Add a link
Reference in a new issue