Работа над проектом

This commit is contained in:
Book Pauk
2022-08-19 18:04:46 +07:00
parent 0b0a51e5d4
commit c0d95115ea
4 changed files with 33 additions and 13 deletions

View File

@@ -83,6 +83,24 @@ const componentOptions = {
config() { config() {
this.makeTitle(); this.makeTitle();
}, },
author() {
this.refresh();
},
series() {
this.refresh();
},
title() {
this.refresh();
},
genre() {
this.refresh();
},
lang() {
this.refresh();
},
limit() {
this.refresh();
},
}, },
}; };
class Search { class Search {
@@ -92,7 +110,7 @@ class Search {
//input field consts //input field consts
inputMaxLength = 1000; inputMaxLength = 1000;
inputDebounce = 400; inputDebounce = 200;
//search fields //search fields
author = ''; author = '';

View File

@@ -86,6 +86,11 @@ class DbCreator {
authorCount++; authorCount++;
} }
//это нужно для того, чтобы имя автора начиналось с заглавной
if (a[0].toUpperCase() === a[0])
authorRec.author = a;
//ссылки на книги
authorRec.bookId.push(id); authorRec.bookId.push(id);
} }
} }

View File

@@ -2,6 +2,8 @@
const utils = require('./utils'); const utils = require('./utils');
const maxUtf8Char = String.fromCodePoint(0xFFFFF);
class DbSearcher { class DbSearcher {
constructor(config, db) { constructor(config, db) {
this.config = config; this.config = config;
@@ -22,9 +24,14 @@ class DbSearcher {
//сначала выберем все id авторов по фильтру //сначала выберем все id авторов по фильтру
//порядок id соответсвует ASC-сортировке по author //порядок id соответсвует ASC-сортировке по author
if (query.author) { if (query.author) {
const a = query.author.toLowerCase(query.author);
authorRows = await db.select({ authorRows = await db.select({
table: 'author', table: 'author',
map: `(r) => ({id: r.id})`, map: `(r) => ({id: r.id})`,
where: `
@@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})
`,
}); });
for (const row of authorRows) for (const row of authorRows)
@@ -136,17 +143,7 @@ class DbSearcher {
let result = await db.select({ let result = await db.select({
table: 'author', table: 'author',
map: `(r) => ({id: r.id, author: r.author})`, map: `(r) => ({id: r.id, author: r.author})`,
where: ` where: `@@id(${db.esc(authorIds.slice(0, limit))})`
const all = @all();
const ids = new Set();
let n = 0;
for (const id of all) {
if (++n > ${db.esc(limit)})
break;
ids.add(id);
}
return ids;
`
}); });
return {result, totalFound}; return {result, totalFound};

View File

@@ -144,7 +144,7 @@ class WebWorker {
db.wwCache = {}; db.wwCache = {};
this.db = db; this.db = db;
log('Searcher DB is ready'); log('Searcher DB ready');
} catch (e) { } catch (e) {
log(LM_FATAL, e.message); log(LM_FATAL, e.message);
ayncExit.exit(1); ayncExit.exit(1);