Browse Source

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

Book Pauk 2 years ago
parent
commit
c0d95115ea

+ 19 - 1
client/components/Search/Search.vue

@@ -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 = '';

+ 5 - 0
server/core/DbCreator.js

@@ -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);
                 }
                 }
             }
             }

+ 8 - 11
server/core/DbSearcher.js

@@ -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: `
-                    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};
             return {result, totalFound};

+ 1 - 1
server/core/WebWorker.js

@@ -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);