mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Merge pull request #3518 from glorenzen/fix-decade-filter
Fix and simplify filter logic for publishedDecades
This commit is contained in:
commit
61b4cfdab7
@ -309,9 +309,9 @@ export const mutations = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add publishedDecades
|
// Add publishedDecades
|
||||||
if (mediaMetadata.publishedYear) {
|
if (mediaMetadata.publishedYear && !isNaN(mediaMetadata.publishedYear)) {
|
||||||
const publishedYear = parseInt(mediaMetadata.publishedYear, 10)
|
const publishedYear = parseInt(mediaMetadata.publishedYear, 10)
|
||||||
const decade = Math.floor(publishedYear / 10) * 10
|
const decade = (Math.floor(publishedYear / 10) * 10).toString()
|
||||||
if (!state.filterData.publishedDecades.includes(decade)) {
|
if (!state.filterData.publishedDecades.includes(decade)) {
|
||||||
state.filterData.publishedDecades.push(decade)
|
state.filterData.publishedDecades.push(decade)
|
||||||
state.filterData.publishedDecades.sort((a, b) => a - b)
|
state.filterData.publishedDecades.sort((a, b) => a - b)
|
||||||
|
@ -508,9 +508,9 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
if (book.publisher) data.publishers.add(book.publisher)
|
if (book.publisher) data.publishers.add(book.publisher)
|
||||||
// Check if published year exists and is valid
|
// 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) {
|
if (book.publishedYear && !isNaN(book.publishedYear) && book.publishedYear > 0 && book.publishedYear < 3000) {
|
||||||
const decade = Math.floor(book.publishedYear / 10) * 10
|
const decade = (Math.floor(book.publishedYear / 10) * 10).toString()
|
||||||
data.publishedDecades.add(decade.toString())
|
data.publishedDecades.add(decade)
|
||||||
}
|
}
|
||||||
if (book.language) data.languages.add(book.language)
|
if (book.language) data.languages.add(book.language)
|
||||||
}
|
}
|
||||||
|
@ -229,10 +229,11 @@ module.exports = {
|
|||||||
mediaWhere['$series.id$'] = null
|
mediaWhere['$series.id$'] = null
|
||||||
}
|
}
|
||||||
} else if (group === 'publishedDecades') {
|
} else if (group === 'publishedDecades') {
|
||||||
const year = parseInt(value, 10)
|
const startYear = parseInt(value)
|
||||||
mediaWhere['publishedYear'] = {
|
const endYear = parseInt(value, 10) + 9
|
||||||
[Sequelize.Op.between]: year >= 1000 ? [year, year + 9] : [year * 10, (year + 1) * 10 - 1]
|
mediaWhere = Sequelize.where(Sequelize.literal('CAST(`book`.`publishedYear` AS INTEGER)'), {
|
||||||
}
|
[Sequelize.Op.between]: [startYear, endYear]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return { mediaWhere, replacements }
|
return { mediaWhere, replacements }
|
||||||
@ -504,7 +505,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let { mediaWhere, replacements } = this.getMediaGroupQuery(filterGroup, filterValue)
|
let { mediaWhere, replacements } = this.getMediaGroupQuery(filterGroup, filterValue)
|
||||||
|
|
||||||
let bookWhere = Array.isArray(mediaWhere) ? mediaWhere : [mediaWhere]
|
let bookWhere = Array.isArray(mediaWhere) ? mediaWhere : [mediaWhere]
|
||||||
|
|
||||||
// User permissions
|
// User permissions
|
||||||
|
Loading…
Reference in New Issue
Block a user