mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-05-04 01:17:19 +02:00
Remove authors search api endpoint
This commit is contained in:
parent
2df95c1712
commit
1b1bdea3c8
@ -153,17 +153,6 @@ class AuthorController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async search(req, res) {
|
|
||||||
var q = (req.query.q || '').toLowerCase()
|
|
||||||
if (!q) return res.json([])
|
|
||||||
var limit = (req.query.limit && !isNaN(req.query.limit)) ? Number(req.query.limit) : 25
|
|
||||||
var authors = Database.authors.filter(au => au.name?.toLowerCase().includes(q))
|
|
||||||
authors = authors.slice(0, limit)
|
|
||||||
res.json({
|
|
||||||
results: authors
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async match(req, res) {
|
async match(req, res) {
|
||||||
let authorData = null
|
let authorData = null
|
||||||
const region = req.body.region || 'us'
|
const region = req.body.region || 'us'
|
||||||
|
@ -209,7 +209,6 @@ class ApiRouter {
|
|||||||
//
|
//
|
||||||
// Author Routes
|
// Author Routes
|
||||||
//
|
//
|
||||||
this.router.get('/authors/search', AuthorController.search.bind(this))
|
|
||||||
this.router.get('/authors/:id', AuthorController.middleware.bind(this), AuthorController.findOne.bind(this))
|
this.router.get('/authors/:id', AuthorController.middleware.bind(this), AuthorController.findOne.bind(this))
|
||||||
this.router.patch('/authors/:id', AuthorController.middleware.bind(this), AuthorController.update.bind(this))
|
this.router.patch('/authors/:id', AuthorController.middleware.bind(this), AuthorController.update.bind(this))
|
||||||
this.router.post('/authors/:id/match', AuthorController.middleware.bind(this), AuthorController.match.bind(this))
|
this.router.post('/authors/:id/match', AuthorController.middleware.bind(this), AuthorController.match.bind(this))
|
||||||
|
@ -209,12 +209,38 @@ class LibraryScanner {
|
|||||||
bookAuthorsToRemove.forEach((authorId) => {
|
bookAuthorsToRemove.forEach((authorId) => {
|
||||||
Database.removeAuthorFromFilterData(libraryScan.libraryId, authorId)
|
Database.removeAuthorFromFilterData(libraryScan.libraryId, authorId)
|
||||||
// TODO: Clients were expecting full author in payload but its unnecessary
|
// TODO: Clients were expecting full author in payload but its unnecessary
|
||||||
SocketAuthority.emitter('author_removed', { id: authorId })
|
SocketAuthority.emitter('author_removed', { id: authorId, libraryId: libraryScan.libraryId })
|
||||||
})
|
})
|
||||||
libraryScan.addLog(LogLevel.INFO, `Removed ${bookAuthorsToRemove.length} authors`)
|
libraryScan.addLog(LogLevel.INFO, `Removed ${bookAuthorsToRemove.length} authors`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check series that were removed from books and remove them if they no longer have any books
|
||||||
|
if (libraryScan.seriesRemovedFromBooks.length) {
|
||||||
|
const bookSeriesToRemove = (await Database.seriesModel.findAll({
|
||||||
|
where: [
|
||||||
|
{
|
||||||
|
id: libraryScan.seriesRemovedFromBooks
|
||||||
|
},
|
||||||
|
sequelize.where(sequelize.literal('(SELECT count(*) FROM bookSeries bs WHERE bs.seriesId = series.id)'), 0)
|
||||||
|
],
|
||||||
|
attributes: ['id'],
|
||||||
|
raw: true
|
||||||
|
})).map(se => se.id)
|
||||||
|
if (bookSeriesToRemove.length) {
|
||||||
|
await Database.seriesModel.destroy({
|
||||||
|
where: {
|
||||||
|
id: bookSeriesToRemove
|
||||||
|
}
|
||||||
|
})
|
||||||
|
bookSeriesToRemove.forEach((seriesId) => {
|
||||||
|
Database.removeSeriesFromFilterData(libraryScan.libraryId, seriesId)
|
||||||
|
SocketAuthority.emitter('series_removed', { id: seriesId, libraryId: libraryScan.libraryId })
|
||||||
|
})
|
||||||
|
libraryScan.addLog(LogLevel.INFO, `Removed ${bookSeriesToRemove.length} series`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update missing library items
|
// Update missing library items
|
||||||
if (libraryItemIdsMissing.length) {
|
if (libraryItemIdsMissing.length) {
|
||||||
libraryScan.addLog(LogLevel.INFO, `Updating ${libraryItemIdsMissing.length} library items missing`)
|
libraryScan.addLog(LogLevel.INFO, `Updating ${libraryItemIdsMissing.length} library items missing`)
|
||||||
|
Loading…
Reference in New Issue
Block a user