mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 18:01:42 +00:00
Updated startedOn sort to match finishedOn, sorting the books with values first always.
This commit is contained in:
parent
d364b35a1a
commit
10ae4c2a6f
1 changed files with 5 additions and 2 deletions
|
|
@ -293,10 +293,13 @@ module.exports = {
|
|||
} else if (sortBy === 'random') {
|
||||
return [Database.sequelize.random()]
|
||||
} else if (sortBy === 'startedDate') {
|
||||
return [[Sequelize.literal('mediaProgresses.createdAt'), dir]]
|
||||
// Sort started books first (not null), then unstarted (nulls last), then by createdAt desc
|
||||
return [
|
||||
[Sequelize.literal('(CASE WHEN mediaProgresses.createdAt IS NULL THEN 1 ELSE 0 END)'), 'ASC'],
|
||||
['mediaProgresses', 'createdAt', dir]
|
||||
]
|
||||
} else if (sortBy === 'finishedDate') {
|
||||
// Sort finished books first (not null), then unfinished (nulls last), then by finishedAt desc
|
||||
// This works for both ASC and DESC, but DESC is typical for "recently finished"
|
||||
return [
|
||||
[Sequelize.literal('(CASE WHEN mediaProgresses.finishedAt IS NULL THEN 1 ELSE 0 END)'), 'ASC'],
|
||||
['mediaProgresses', 'finishedAt', dir]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue