mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-05-27 01:18:24 +02:00
Update:Author endpoints to use faster db call to get number of books
This commit is contained in:
parent
56c0124c13
commit
67b47785a0
@ -252,7 +252,7 @@ class AuthorController {
|
|||||||
req.author.updatedAt = Date.now()
|
req.author.updatedAt = Date.now()
|
||||||
await Database.authorModel.updateFromOld(req.author)
|
await Database.authorModel.updateFromOld(req.author)
|
||||||
|
|
||||||
const numBooks = (await Database.libraryItemModel.getForAuthor(req.author)).length
|
const numBooks = await Database.bookAuthorModel.getCountForAuthor(req.author.id)
|
||||||
SocketAuthority.emitter('author_updated', req.author.toJSONExpanded(numBooks))
|
SocketAuthority.emitter('author_updated', req.author.toJSONExpanded(numBooks))
|
||||||
res.json({
|
res.json({
|
||||||
author: req.author.toJSON()
|
author: req.author.toJSON()
|
||||||
@ -277,7 +277,7 @@ class AuthorController {
|
|||||||
req.author.imagePath = null
|
req.author.imagePath = null
|
||||||
await Database.authorModel.updateFromOld(req.author)
|
await Database.authorModel.updateFromOld(req.author)
|
||||||
|
|
||||||
const numBooks = (await Database.libraryItemModel.getForAuthor(req.author)).length
|
const numBooks = await Database.bookAuthorModel.getCountForAuthor(req.author.id)
|
||||||
SocketAuthority.emitter('author_updated', req.author.toJSONExpanded(numBooks))
|
SocketAuthority.emitter('author_updated', req.author.toJSONExpanded(numBooks))
|
||||||
res.json({
|
res.json({
|
||||||
author: req.author.toJSON()
|
author: req.author.toJSON()
|
||||||
@ -324,7 +324,7 @@ class AuthorController {
|
|||||||
|
|
||||||
await Database.updateAuthor(req.author)
|
await Database.updateAuthor(req.author)
|
||||||
|
|
||||||
const numBooks = (await Database.libraryItemModel.getForAuthor(req.author)).length
|
const numBooks = await Database.bookAuthorModel.getCountForAuthor(req.author.id)
|
||||||
SocketAuthority.emitter('author_updated', req.author.toJSONExpanded(numBooks))
|
SocketAuthority.emitter('author_updated', req.author.toJSONExpanded(numBooks))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user