mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Scan for empty book series more efficiently
This commit is contained in:
parent
ab97a9d613
commit
8b39b01269
@ -684,7 +684,15 @@ class Database {
|
|||||||
|
|
||||||
// Remove empty series
|
// Remove empty series
|
||||||
const emptySeries = await this.seriesModel.findAll({
|
const emptySeries = await this.seriesModel.findAll({
|
||||||
where: Sequelize.where(Sequelize.literal(`(SELECT count(*) FROM bookSeries bs WHERE bs.seriesId = series.id)`), 0)
|
attributes: ['series.id', 'series.name', [this.sequelize.fn('COUNT', '*'), 'book_count']],
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: this.bookSeriesModel,
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
group:["series.id", 'series.name'],
|
||||||
|
having: { 'book_count': 0 }
|
||||||
})
|
})
|
||||||
for (const series of emptySeries) {
|
for (const series of emptySeries) {
|
||||||
Logger.warn(`Found series "${series.name}" with no books - removing it`)
|
Logger.warn(`Found series "${series.name}" with no books - removing it`)
|
||||||
|
Loading…
Reference in New Issue
Block a user