Fix:Book library author name sort order with multi-author books #2859

This commit is contained in:
advplyr 2024-05-16 14:56:19 -05:00
parent c995816076
commit a11cf7a90e

View File

@ -360,11 +360,11 @@ module.exports = {
let bookAttributes = null let bookAttributes = null
if (sortBy === 'media.metadata.authorNameLF') { if (sortBy === 'media.metadata.authorNameLF') {
bookAttributes = { bookAttributes = {
include: [[Sequelize.literal(`(SELECT group_concat(a.lastFirst, ", ") FROM authors AS a, bookAuthors as ba WHERE ba.authorId = a.id AND ba.bookId = book.id)`), 'author_name']] include: [[Sequelize.literal(`(SELECT group_concat(lastFirst, ", ") FROM (SELECT a.lastFirst FROM authors AS a, bookAuthors as ba WHERE ba.authorId = a.id AND ba.bookId = book.id ORDER BY ba.createdAt ASC))`), 'author_name']]
} }
} else if (sortBy === 'media.metadata.authorName') { } else if (sortBy === 'media.metadata.authorName') {
bookAttributes = { bookAttributes = {
include: [[Sequelize.literal(`(SELECT group_concat(a.name, ", ") FROM authors AS a, bookAuthors as ba WHERE ba.authorId = a.id AND ba.bookId = book.id)`), 'author_name']] include: [[Sequelize.literal(`(SELECT group_concat(name, ", ") FROM (SELECT a.name FROM authors AS a, bookAuthors as ba WHERE ba.authorId = a.id AND ba.bookId = book.id ORDER BY ba.createdAt ASC))`), 'author_name']]
} }
} }