Issue 4540 New SortBy Options: Started Date & Finished Date (#4575)

---------

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

@ -353,6 +353,14 @@ export default {
if (!this.userProgressLastUpdated) return '\u00A0' if (!this.userProgressLastUpdated) return '\u00A0'
return this.$getString('LabelLastProgressDate', [this.$formatDatetime(this.userProgressLastUpdated, this.dateFormat, this.timeFormat)]) return this.$getString('LabelLastProgressDate', [this.$formatDatetime(this.userProgressLastUpdated, this.dateFormat, this.timeFormat)])
} }
if (this.orderBy === 'progress.createdAt') {
if (!this.userProgressStartedDate) return '\u00A0'
return this.$getString('LabelStartedDate', [this.$formatDatetime(this.userProgressStartedDate, this.dateFormat, this.timeFormat)])
}
if (this.orderBy === 'progress.finishedAt') {
if (!this.userProgressFinishedDate) return '\u00A0'
return this.$getString('LabelFinishedDate', [this.$formatDatetime(this.userProgressFinishedDate, this.dateFormat, this.timeFormat)])
}
return null return null
}, },
episodeProgress() { episodeProgress() {
@ -389,6 +397,14 @@ export default {
if (!this.userProgress) return null if (!this.userProgress) return null
return this.userProgress.lastUpdate return this.userProgress.lastUpdate
}, },
userProgressStartedDate() {
if (!this.userProgress) return null
return this.userProgress.startedAt
},
userProgressFinishedDate() {
if (!this.userProgress) return null
return this.userProgress.finishedAt
},
itemIsFinished() { itemIsFinished() {
if (this.booksInSeries) return this.seriesIsFinished if (this.booksInSeries) return this.seriesIsFinished
return this.userProgress ? !!this.userProgress.isFinished : false return this.userProgress ? !!this.userProgress.isFinished : false

View File

@ -134,6 +134,14 @@ export default {
text: this.$strings.LabelLibrarySortByProgress, text: this.$strings.LabelLibrarySortByProgress,
value: 'progress' value: 'progress'
}, },
{
text: this.$strings.LabelLibrarySortByProgressStarted,
value: 'progress.createdAt'
},
{
text: this.$strings.LabelLibrarySortByProgressFinished,
value: 'progress.finishedAt'
},
{ {
text: this.$strings.LabelRandomly, text: this.$strings.LabelRandomly,
value: 'random' value: 'random'

View File

@ -378,6 +378,7 @@
"LabelFilterByUser": "Filter by User", "LabelFilterByUser": "Filter by User",
"LabelFindEpisodes": "Find Episodes", "LabelFindEpisodes": "Find Episodes",
"LabelFinished": "Finished", "LabelFinished": "Finished",
"LabelFinishedDate": "Finished {0}",
"LabelFolder": "Folder", "LabelFolder": "Folder",
"LabelFolders": "Folders", "LabelFolders": "Folders",
"LabelFontBold": "Bold", "LabelFontBold": "Bold",
@ -436,6 +437,8 @@
"LabelLibraryItem": "Library Item", "LabelLibraryItem": "Library Item",
"LabelLibraryName": "Library Name", "LabelLibraryName": "Library Name",
"LabelLibrarySortByProgress": "Progress Updated", "LabelLibrarySortByProgress": "Progress Updated",
"LabelLibrarySortByProgressFinished": "Finished Date",
"LabelLibrarySortByProgressStarted": "Started Date",
"LabelLimit": "Limit", "LabelLimit": "Limit",
"LabelLineSpacing": "Line spacing", "LabelLineSpacing": "Line spacing",
"LabelListenAgain": "Listen Again", "LabelListenAgain": "Listen Again",
@ -635,6 +638,7 @@
"LabelStartTime": "Start Time", "LabelStartTime": "Start Time",
"LabelStarted": "Started", "LabelStarted": "Started",
"LabelStartedAt": "Started At", "LabelStartedAt": "Started At",
"LabelStartedDate": "Started {0}",
"LabelStatsAudioTracks": "Audio Tracks", "LabelStatsAudioTracks": "Audio Tracks",
"LabelStatsAuthors": "Authors", "LabelStatsAuthors": "Authors",
"LabelStatsBestDay": "Best Day", "LabelStatsBestDay": "Best Day",

View File

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