Добавлено отображение общего количества книг в серии, без ее раскрытия
This commit is contained in:
@@ -89,6 +89,8 @@ class WebSocketController {
|
||||
await this.search(req, ws); break;
|
||||
case 'get-author-book-list':
|
||||
await this.getAuthorBookList(req, ws); break;
|
||||
case 'get-author-series-list':
|
||||
await this.getAuthorSeriesList(req, ws); break;
|
||||
case 'get-series-book-list':
|
||||
await this.getSeriesBookList(req, ws); break;
|
||||
case 'get-genre-tree':
|
||||
@@ -169,6 +171,12 @@ class WebSocketController {
|
||||
this.send(result, req, ws);
|
||||
}
|
||||
|
||||
async getAuthorSeriesList(req, ws) {
|
||||
const result = await this.webWorker.getAuthorSeriesList(req.authorId);
|
||||
|
||||
this.send(result, req, ws);
|
||||
}
|
||||
|
||||
async getSeriesBookList(req, ws) {
|
||||
const result = await this.webWorker.getSeriesBookList(req.series);
|
||||
|
||||
|
||||
@@ -599,7 +599,7 @@ class DbSearcher {
|
||||
throw new Error('DbSearcher closed');
|
||||
|
||||
if (!authorId && !author)
|
||||
return {author: '', books: ''};
|
||||
return {author: '', books: []};
|
||||
|
||||
this.searchFlag++;
|
||||
|
||||
@@ -638,12 +638,58 @@ class DbSearcher {
|
||||
}
|
||||
}
|
||||
|
||||
async getAuthorSeriesList(authorId) {
|
||||
if (this.closed)
|
||||
throw new Error('DbSearcher closed');
|
||||
|
||||
if (!authorId)
|
||||
return {author: '', series: []};
|
||||
|
||||
this.searchFlag++;
|
||||
|
||||
try {
|
||||
const db = this.db;
|
||||
|
||||
//выборка книг автора по authorId
|
||||
const bookList = await this.getAuthorBookList(authorId);
|
||||
const books = bookList.books;
|
||||
const seriesSet = new Set();
|
||||
for (const book of books) {
|
||||
if (book.series)
|
||||
seriesSet.add(book.series.toLowerCase());
|
||||
}
|
||||
|
||||
let series = [];
|
||||
if (seriesSet.size) {
|
||||
//выборка серий по названиям
|
||||
series = await db.select({
|
||||
table: 'series',
|
||||
map: `(r) => ({id: r.id, series: r.name, bookCount: r.bookCount, bookDelCount: r.bookDelCount})`,
|
||||
where: `
|
||||
const seriesArr = ${db.esc(Array.from(seriesSet))};
|
||||
const ids = new Set();
|
||||
for (const value of seriesArr) {
|
||||
for (const id of @dirtyIndexLR('value', value, value))
|
||||
ids.add(id);
|
||||
}
|
||||
|
||||
return ids;
|
||||
`
|
||||
});
|
||||
}
|
||||
|
||||
return {author: bookList.author, series};
|
||||
} finally {
|
||||
this.searchFlag--;
|
||||
}
|
||||
}
|
||||
|
||||
async getSeriesBookList(series) {
|
||||
if (this.closed)
|
||||
throw new Error('DbSearcher closed');
|
||||
|
||||
if (!series)
|
||||
return {books: ''};
|
||||
return {books: []};
|
||||
|
||||
this.searchFlag++;
|
||||
|
||||
|
||||
@@ -279,6 +279,12 @@ class WebWorker {
|
||||
return await this.dbSearcher.getAuthorBookList(authorId, author);
|
||||
}
|
||||
|
||||
async getAuthorSeriesList(authorId) {
|
||||
this.checkMyState();
|
||||
|
||||
return await this.dbSearcher.getAuthorSeriesList(authorId);
|
||||
}
|
||||
|
||||
async getSeriesBookList(series) {
|
||||
this.checkMyState();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user