mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-10 19:31:39 +00:00
Add publishedDecades to getFilterData
This commit is contained in:
parent
8c19a35f5d
commit
1532964902
1 changed files with 9 additions and 2 deletions
|
|
@ -26,7 +26,7 @@ module.exports = {
|
||||||
let filterValue = null
|
let filterValue = null
|
||||||
let filterGroup = null
|
let filterGroup = null
|
||||||
if (filterBy) {
|
if (filterBy) {
|
||||||
const searchGroups = ['genres', 'tags', 'series', 'authors', 'progress', 'narrators', 'publishers', 'missing', 'languages', 'tracks', 'ebooks']
|
const searchGroups = ['genres', 'tags', 'series', 'authors', 'progress', 'narrators', 'publishers', 'publishedDecades', 'missing', 'languages', 'tracks', 'ebooks']
|
||||||
const group = searchGroups.find((_group) => filterBy.startsWith(_group + '.'))
|
const group = searchGroups.find((_group) => filterBy.startsWith(_group + '.'))
|
||||||
filterGroup = group || filterBy
|
filterGroup = group || filterBy
|
||||||
filterValue = group ? this.decode(filterBy.replace(`${group}.`, '')) : null
|
filterValue = group ? this.decode(filterBy.replace(`${group}.`, '')) : null
|
||||||
|
|
@ -458,6 +458,7 @@ module.exports = {
|
||||||
narrators: new Set(),
|
narrators: new Set(),
|
||||||
languages: new Set(),
|
languages: new Set(),
|
||||||
publishers: new Set(),
|
publishers: new Set(),
|
||||||
|
publishedDecades: new Set(),
|
||||||
numIssues: 0
|
numIssues: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -492,7 +493,7 @@ module.exports = {
|
||||||
libraryId: libraryId
|
libraryId: libraryId
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
attributes: ['tags', 'genres', 'publisher', 'narrators', 'language']
|
attributes: ['tags', 'genres', 'publisher', 'publishedYear', 'narrators', 'language']
|
||||||
})
|
})
|
||||||
for (const book of books) {
|
for (const book of books) {
|
||||||
if (book.libraryItem.isMissing || book.libraryItem.isInvalid) data.numIssues++
|
if (book.libraryItem.isMissing || book.libraryItem.isInvalid) data.numIssues++
|
||||||
|
|
@ -506,6 +507,11 @@ module.exports = {
|
||||||
book.narrators.forEach((narrator) => data.narrators.add(narrator))
|
book.narrators.forEach((narrator) => data.narrators.add(narrator))
|
||||||
}
|
}
|
||||||
if (book.publisher) data.publishers.add(book.publisher)
|
if (book.publisher) data.publishers.add(book.publisher)
|
||||||
|
// Check if published year exists and is valid
|
||||||
|
if (book.publishedYear && !isNaN(book.publishedYear) && book.publishedYear > 0 && book.publishedYear < 3000 && book.publishedYear.toString().length === 4) {
|
||||||
|
const decade = Math.floor(book.publishedYear / 10) * 10
|
||||||
|
data.publishedDecades.add(decade.toString())
|
||||||
|
}
|
||||||
if (book.language) data.languages.add(book.language)
|
if (book.language) data.languages.add(book.language)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,6 +538,7 @@ module.exports = {
|
||||||
data.series = naturalSort(data.series).asc((se) => se.name)
|
data.series = naturalSort(data.series).asc((se) => se.name)
|
||||||
data.narrators = naturalSort([...data.narrators]).asc()
|
data.narrators = naturalSort([...data.narrators]).asc()
|
||||||
data.publishers = naturalSort([...data.publishers]).asc()
|
data.publishers = naturalSort([...data.publishers]).asc()
|
||||||
|
data.publishedDecades = naturalSort([...data.publishedDecades]).asc()
|
||||||
data.languages = naturalSort([...data.languages]).asc()
|
data.languages = naturalSort([...data.languages]).asc()
|
||||||
data.loadedAt = Date.now()
|
data.loadedAt = Date.now()
|
||||||
Database.libraryFilterData[libraryId] = data
|
Database.libraryFilterData[libraryId] = data
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue