Fix and simplify filter logic for publishedDecades

This commit is contained in:
Greg Lorenzen 2024-10-14 20:58:09 +00:00
parent 13dd4edd6a
commit 217038b085

View File

@ -229,9 +229,10 @@ module.exports = {
mediaWhere['$series.id$'] = null
}
} else if (group === 'publishedDecades') {
const year = parseInt(value, 10)
const startYear = value.padStart(4, '0')
const endYear = (parseInt(value, 10) + 9).toString().padStart(4, '0')
mediaWhere['publishedYear'] = {
[Sequelize.Op.between]: year >= 1000 ? [year, year + 9] : [year * 10, (year + 1) * 10 - 1]
[Sequelize.Op.between]: [startYear, endYear]
}
}