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

This commit is contained in:
Book Pauk
2022-10-30 16:44:51 +07:00
parent c904990eed
commit fba7300131
3 changed files with 31 additions and 25 deletions

View File

@@ -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.queryFound = response.found.length;
this.list.totalFound = result.totalFound; this.list.totalFound = response.totalFound;
this.list.inpxHash = result.inpxHash; 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) {

View File

@@ -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.queryFound = response.found.length;
this.list.totalFound = result.totalFound; this.list.totalFound = response.totalFound;
this.list.inpxHash = result.inpxHash; 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) {

View File

@@ -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({ (async() => {
table: 'query_cache', try {
replace: true, await db.insert({
rows: [{id: key, value}], table: 'query_cache',
}); replace: true,
rows: [{id: key, value}],
});
await db.insert({ await db.insert({
table: 'query_time', table: 'query_time',
replace: true, replace: true,
rows: [{id: key, time: Date.now()}], rows: [{id: key, time: Date.now()}],
}); });
} catch(e) {
console.error(`putCached: ${e.message}`);
}
})();
} }
async periodicCleanCache() { async periodicCleanCache() {