From 217038b085c8be5cf5ef0781c4ff87f8d518e730 Mon Sep 17 00:00:00 2001 From: Greg Lorenzen Date: Mon, 14 Oct 2024 20:58:09 +0000 Subject: [PATCH] Fix and simplify filter logic for publishedDecades --- server/utils/queries/libraryItemsBookFilters.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/utils/queries/libraryItemsBookFilters.js b/server/utils/queries/libraryItemsBookFilters.js index e64e7b78..4b56bc47 100644 --- a/server/utils/queries/libraryItemsBookFilters.js +++ b/server/utils/queries/libraryItemsBookFilters.js @@ -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] } }