From fba730013106b769eca9bfa936342a9bb2398b39 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 30 Oct 2022 16:44:51 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=BC=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Search/SeriesList/SeriesList.vue | 12 +++---- .../components/Search/TitleList/TitleList.vue | 12 +++---- server/core/DbSearcher.js | 32 +++++++++++-------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/client/components/Search/SeriesList/SeriesList.vue b/client/components/Search/SeriesList/SeriesList.vue index 3a15987..b50b50e 100644 --- a/client/components/Search/SeriesList/SeriesList.vue +++ b/client/components/Search/SeriesList/SeriesList.vue @@ -181,7 +181,7 @@ class SeriesList extends BaseList { let result = []; const expandedSet = new Set(this.expandedSeries); - const series = this.searchResult.series; + const series = this.searchResult.found; if (!series) return; @@ -256,13 +256,13 @@ class SeriesList extends BaseList { this.queryExecute = null; try { - const result = await this.api.seriesSearch(query); + const response = await this.api.search('series', query); - this.list.queryFound = result.series.length; - this.list.totalFound = result.totalFound; - this.list.inpxHash = result.inpxHash; + this.list.queryFound = response.found.length; + this.list.totalFound = response.totalFound; + this.list.inpxHash = response.inpxHash; - this.searchResult = result; + this.searchResult = response; await utils.sleep(1); if (!this.queryExecute) { diff --git a/client/components/Search/TitleList/TitleList.vue b/client/components/Search/TitleList/TitleList.vue index 84693ec..f0bf34d 100644 --- a/client/components/Search/TitleList/TitleList.vue +++ b/client/components/Search/TitleList/TitleList.vue @@ -49,7 +49,7 @@ class TitleList extends BaseList { async updateTableData() { let result = []; - const title = this.searchResult.title; + const title = this.searchResult.found; if (!title) return; @@ -116,13 +116,13 @@ class TitleList extends BaseList { this.queryExecute = null; try { - const result = await this.api.titleSearch(query); + const response = await this.api.search('title', query); - this.list.queryFound = result.title.length; - this.list.totalFound = result.totalFound; - this.list.inpxHash = result.inpxHash; + this.list.queryFound = response.found.length; + this.list.totalFound = response.totalFound; + this.list.inpxHash = response.inpxHash; - this.searchResult = result; + this.searchResult = response; await utils.sleep(1); if (!this.queryExecute) { diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js index 569dc47..4f64639 100644 --- a/server/core/DbSearcher.js +++ b/server/core/DbSearcher.js @@ -318,8 +318,8 @@ class DbSearcher { async filterTableIds(tableIds, from, query) { let result = tableIds; - //т.к. авторы идут списком, то дополнительно фильтруем - if (query.author && query.author !== '*') { + //т.к. авторы у книги идут списком, то дополнительно фильтруем + if (from == 'author' && query.author && query.author !== '*') { const key = `filter-ids-author-${query.author}`; let authorIds = await this.getCached(key); @@ -591,18 +591,24 @@ class DbSearcher { } } - //кладем в таблицу - await db.insert({ - table: 'query_cache', - replace: true, - rows: [{id: key, value}], - }); + //кладем в таблицу асинхронно + (async() => { + try { + await db.insert({ + table: 'query_cache', + replace: true, + rows: [{id: key, value}], + }); - await db.insert({ - table: 'query_time', - replace: true, - rows: [{id: key, time: Date.now()}], - }); + await db.insert({ + table: 'query_time', + replace: true, + rows: [{id: key, time: Date.now()}], + }); + } catch(e) { + console.error(`putCached: ${e.message}`); + } + })(); } async periodicCleanCache() {