Добавлено отображение общего количества книг в серии, без ее раскрытия
This commit is contained in:
@@ -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