Fix count cache by stringify Symbols #3979

This commit is contained in:
advplyr 2025-02-13 18:07:59 -06:00
parent ebdf377fc1
commit 5ca12eee19
2 changed files with 37 additions and 2 deletions

View file

@ -5,7 +5,7 @@ const authorFilters = require('./authorFilters')
const ShareManager = require('../../managers/ShareManager')
const { profile } = require('../profiler')
const stringifySequelizeQuery = require('../stringifySequelizeQuery')
const countCache = new Map()
module.exports = {
@ -345,7 +345,7 @@ module.exports = {
},
async findAndCountAll(findOptions, limit, offset) {
const findOptionsKey = JSON.stringify(findOptions)
const findOptionsKey = stringifySequelizeQuery(findOptions)
Logger.debug(`[LibraryItemsBookFilters] findOptionsKey: ${findOptionsKey}`)
findOptions.limit = limit || null
@ -353,6 +353,7 @@ module.exports = {
if (countCache.has(findOptionsKey)) {
const rows = await Database.bookModel.findAll(findOptions)
return { rows, count: countCache.get(findOptionsKey) }
} else {
const result = await Database.bookModel.findAndCountAll(findOptions)