Răsfoiți Sursa

Работа над новым поиском

Book Pauk 2 ani în urmă
părinte
comite
fba7300131

+ 6 - 6
client/components/Search/SeriesList/SeriesList.vue

@@ -181,7 +181,7 @@ class SeriesList extends BaseList {
         let result = [];
         let result = [];
 
 
         const expandedSet = new Set(this.expandedSeries);
         const expandedSet = new Set(this.expandedSeries);
-        const series = this.searchResult.series;
+        const series = this.searchResult.found;
         if (!series)
         if (!series)
             return;
             return;
 
 
@@ -256,13 +256,13 @@ class SeriesList extends BaseList {
                 this.queryExecute = null;
                 this.queryExecute = null;
 
 
                 try {
                 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);
                     await utils.sleep(1);
                     if (!this.queryExecute) {
                     if (!this.queryExecute) {

+ 6 - 6
client/components/Search/TitleList/TitleList.vue

@@ -49,7 +49,7 @@ class TitleList extends BaseList {
     async updateTableData() {
     async updateTableData() {
         let result = [];
         let result = [];
 
 
-        const title = this.searchResult.title;
+        const title = this.searchResult.found;
         if (!title)
         if (!title)
             return;
             return;
 
 
@@ -116,13 +116,13 @@ class TitleList extends BaseList {
                 this.queryExecute = null;
                 this.queryExecute = null;
 
 
                 try {
                 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);
                     await utils.sleep(1);
                     if (!this.queryExecute) {
                     if (!this.queryExecute) {

+ 19 - 13
server/core/DbSearcher.js

@@ -318,8 +318,8 @@ class DbSearcher {
     async filterTableIds(tableIds, from, query) {
     async filterTableIds(tableIds, from, query) {
         let result = tableIds;
         let result = tableIds;
 
 
-        //т.к. авторы идут списком, то дополнительно фильтруем
-        if (query.author && query.author !== '*') {
+        //т.к. авторы у книги идут списком, то дополнительно фильтруем
+        if (from == 'author' && query.author && query.author !== '*') {
             const key = `filter-ids-author-${query.author}`;
             const key = `filter-ids-author-${query.author}`;
             let authorIds = await this.getCached(key);
             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() {
     async periodicCleanCache() {