Issue 4540 New SortBy Options: Started Date & Finished Date (#4575)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Run Component Tests / Run Component Tests (push) Waiting to run
Build and Push Docker Image / build (push) Waiting to run
Verify all i18n files are alphabetized / update_translations (push) Waiting to run
Integration Test / build and test (push) Waiting to run
Run Unit Tests / Run Unit Tests (push) Waiting to run

---------

Co-authored-by: advplyr <advplyr@protonmail.com>
This commit is contained in:
John 2025-08-24 16:54:38 -05:00 committed by GitHub
parent e258f122f1
commit 18ad23d016
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 5 deletions

View file

@ -289,7 +289,11 @@ module.exports = {
const nullDir = sortDesc ? 'DESC NULLS FIRST' : 'ASC NULLS LAST'
return [[Sequelize.literal(`CAST(\`series.bookSeries.sequence\` AS FLOAT) ${nullDir}`)]]
} else if (sortBy === 'progress') {
return [[Sequelize.literal('mediaProgresses.updatedAt'), dir]]
return [[Sequelize.literal(`mediaProgresses.updatedAt ${dir} NULLS LAST`)]]
} else if (sortBy === 'progress.createdAt') {
return [[Sequelize.literal(`mediaProgresses.createdAt ${dir} NULLS LAST`)]]
} else if (sortBy === 'progress.finishedAt') {
return [[Sequelize.literal(`mediaProgresses.finishedAt ${dir} NULLS LAST`)]]
} else if (sortBy === 'random') {
return [Database.sequelize.random()]
}
@ -519,7 +523,7 @@ module.exports = {
}
bookIncludes.push({
model: Database.mediaProgressModel,
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt'],
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt', 'createdAt', 'finishedAt'],
where: mediaProgressWhere,
required: false
})
@ -530,10 +534,10 @@ module.exports = {
}
// When sorting by progress but not filtering by progress, include media progresses
if (filterGroup !== 'progress' && sortBy === 'progress') {
if (filterGroup !== 'progress' && ['progress.createdAt', 'progress.finishedAt', 'progress'].includes(sortBy)) {
bookIncludes.push({
model: Database.mediaProgressModel,
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt'],
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt', 'createdAt', 'finishedAt'],
where: {
userId: user.id
},