diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js index da47dd4..43b9aa6 100644 --- a/server/core/DbSearcher.js +++ b/server/core/DbSearcher.js @@ -55,7 +55,7 @@ class DbSearcher { async selectAuthorIds(query) { const db = this.db; - let authorIds = new Set(); + let authorIds = []; //сначала выберем все id авторов по фильтру //порядок id соответсвует ASC-сортировке по author @@ -69,7 +69,7 @@ class DbSearcher { }); for (const row of authorRows) - authorIds.add(row.id); + authorIds.push(row.id); } else {//все авторы if (!db.searchCache.authorIdsAll) { const authorRows = await db.select({ @@ -77,18 +77,17 @@ class DbSearcher { dirtyIdsOnly: true, }); - db.searchCache.authorIdsAll = []; for (const row of authorRows) { - authorIds.add(row.id); - db.searchCache.authorIdsAll.push(row.id); + authorIds.push(row.id); } + + db.searchCache.authorIdsAll = authorIds; } else {//оптимизация - authorIds = new Set(db.searchCache.authorIdsAll); + authorIds = db.searchCache.authorIdsAll; } } const idsArr = []; - idsArr.push(authorIds); //серии if (query.series && query.series !== '*') { @@ -176,12 +175,13 @@ class DbSearcher { idsArr.push(ids); } - if (idsArr.length > 1) - authorIds = utils.intersectSet(idsArr); + if (idsArr.length) { + //ищем пересечение множеств + idsArr.push(new Set(authorIds)); + authorIds = Array.from(utils.intersectSet(idsArr)); + } //сортировка - authorIds = Array.from(authorIds); - authorIds.sort((a, b) => a - b); return authorIds;