From 88d49852e0af697879000a1c57183362127877ac Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 20 Oct 2022 14:16:44 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/DbSearcher.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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;