Работа над проектом
This commit is contained in:
@@ -83,6 +83,24 @@ const componentOptions = {
|
||||
config() {
|
||||
this.makeTitle();
|
||||
},
|
||||
author() {
|
||||
this.refresh();
|
||||
},
|
||||
series() {
|
||||
this.refresh();
|
||||
},
|
||||
title() {
|
||||
this.refresh();
|
||||
},
|
||||
genre() {
|
||||
this.refresh();
|
||||
},
|
||||
lang() {
|
||||
this.refresh();
|
||||
},
|
||||
limit() {
|
||||
this.refresh();
|
||||
},
|
||||
},
|
||||
};
|
||||
class Search {
|
||||
@@ -92,7 +110,7 @@ class Search {
|
||||
|
||||
//input field consts
|
||||
inputMaxLength = 1000;
|
||||
inputDebounce = 400;
|
||||
inputDebounce = 200;
|
||||
|
||||
//search fields
|
||||
author = '';
|
||||
|
||||
@@ -86,6 +86,11 @@ class DbCreator {
|
||||
authorCount++;
|
||||
}
|
||||
|
||||
//это нужно для того, чтобы имя автора начиналось с заглавной
|
||||
if (a[0].toUpperCase() === a[0])
|
||||
authorRec.author = a;
|
||||
|
||||
//ссылки на книги
|
||||
authorRec.bookId.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
const maxUtf8Char = String.fromCodePoint(0xFFFFF);
|
||||
|
||||
class DbSearcher {
|
||||
constructor(config, db) {
|
||||
this.config = config;
|
||||
@@ -22,9 +24,14 @@ class DbSearcher {
|
||||
//сначала выберем все id авторов по фильтру
|
||||
//порядок id соответсвует ASC-сортировке по author
|
||||
if (query.author) {
|
||||
const a = query.author.toLowerCase(query.author);
|
||||
|
||||
authorRows = await db.select({
|
||||
table: 'author',
|
||||
map: `(r) => ({id: r.id})`,
|
||||
where: `
|
||||
@@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})
|
||||
`,
|
||||
});
|
||||
|
||||
for (const row of authorRows)
|
||||
@@ -136,17 +143,7 @@ class DbSearcher {
|
||||
let result = await db.select({
|
||||
table: 'author',
|
||||
map: `(r) => ({id: r.id, author: r.author})`,
|
||||
where: `
|
||||
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;
|
||||
`
|
||||
where: `@@id(${db.esc(authorIds.slice(0, limit))})`
|
||||
});
|
||||
|
||||
return {result, totalFound};
|
||||
|
||||
@@ -144,7 +144,7 @@ class WebWorker {
|
||||
db.wwCache = {};
|
||||
this.db = db;
|
||||
|
||||
log('Searcher DB is ready');
|
||||
log('Searcher DB ready');
|
||||
} catch (e) {
|
||||
log(LM_FATAL, e.message);
|
||||
ayncExit.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user