mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-08-29 06:37:16 +02:00
fix: collapsed series query with active filters
This commit is contained in:
@@ -309,11 +309,12 @@ module.exports = {
|
|||||||
* @param {Sequelize.WhereOptions} seriesWhere
|
* @param {Sequelize.WhereOptions} seriesWhere
|
||||||
* @returns {object} { booksToExclude, bookSeriesToInclude }
|
* @returns {object} { booksToExclude, bookSeriesToInclude }
|
||||||
*/
|
*/
|
||||||
async getCollapseSeriesBooksToExclude(bookFindOptions, seriesWhere) {
|
async getCollapseSeriesBooksToExclude(bookFindOptions, seriesWhere, replacements = {}) {
|
||||||
const allSeries = await Database.seriesModel.findAll({
|
const allSeries = await Database.seriesModel.findAll({
|
||||||
attributes: ['id', 'name', [Sequelize.literal('(SELECT count(*) FROM bookSeries bs WHERE bs.seriesId = series.id)'), 'numBooks']],
|
attributes: ['id', 'name', [Sequelize.literal('(SELECT count(*) FROM bookSeries bs WHERE bs.seriesId = series.id)'), 'numBooks']],
|
||||||
distinct: true,
|
distinct: true,
|
||||||
subQuery: false,
|
subQuery: false,
|
||||||
|
replacements,
|
||||||
where: seriesWhere,
|
where: seriesWhere,
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
@@ -581,7 +582,7 @@ module.exports = {
|
|||||||
...bookIncludes
|
...bookIncludes
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
const { booksToExclude, bookSeriesToInclude } = await this.getCollapseSeriesBooksToExclude(bookFindOptions, seriesWhere)
|
const { booksToExclude, bookSeriesToInclude } = await this.getCollapseSeriesBooksToExclude(bookFindOptions, seriesWhere, replacements)
|
||||||
if (booksToExclude.length) {
|
if (booksToExclude.length) {
|
||||||
bookWhere.push({
|
bookWhere.push({
|
||||||
id: {
|
id: {
|
||||||
|
|||||||
Reference in New Issue
Block a user