mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 09:51:37 +00:00
fix: collapsed series query with active filters
This commit is contained in:
parent
e70e4b9d40
commit
4502d37d4f
1 changed files with 3 additions and 2 deletions
|
|
@ -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: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue