mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-24 14:37:14 -04:00
Fix count cache by stringify Symbols #3979
This commit is contained in:
parent
ebdf377fc1
commit
5ca12eee19
2 changed files with 37 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue