This commit is contained in:
Rapha149 2026-05-06 13:51:21 +02:00 committed by GitHub
commit 8e28f36579
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 310 additions and 12 deletions

View file

@ -106,7 +106,11 @@ module.exports = {
let mediaWhere = {}
const replacements = {}
if (group === 'progress') {
if (group === 'favorite') {
mediaWhere['$libraryItem.userFavorites.userId$'] = {
[Sequelize.Op.not]: null
}
} else if (group === 'progress') {
if (value === 'not-finished') {
mediaWhere['$mediaProgresses.isFinished$'] = {
[Sequelize.Op.or]: [null, false]
@ -531,6 +535,15 @@ module.exports = {
libraryItemWhere['createdAt'] = {
[Sequelize.Op.gte]: new Date(new Date() - 60 * 24 * 60 * 60 * 1000) // 60 days ago
}
} else if (filterGroup === 'favorite' && user) {
libraryItemIncludes.push({
model: Database.userFavoriteModel,
attributes: ['userId'],
where: {
userId: user.id
},
required: true
})
}
// When sorting by progress but not filtering by progress, include media progresses

View file

@ -52,7 +52,11 @@ module.exports = {
let mediaWhere = {}
const replacements = {}
if (['genres', 'tags'].includes(group)) {
if (group === 'favorite') {
mediaWhere['$libraryItem.userFavorites.userId$'] = {
[Sequelize.Op.not]: null
}
} else if (['genres', 'tags'].includes(group)) {
mediaWhere[group] = Sequelize.where(Sequelize.literal(`(SELECT count(*) FROM json_each(${group}) WHERE json_valid(${group}) AND json_each.value = :filterValue)`), {
[Sequelize.Op.gte]: 1
})
@ -172,6 +176,15 @@ module.exports = {
libraryItemWhere['createdAt'] = {
[Sequelize.Op.gte]: new Date(new Date() - 60 * 24 * 60 * 60 * 1000) // 60 days ago
}
} else if (filterGroup === 'favorite' && user) {
libraryItemIncludes.push({
model: Database.userFavoriteModel,
attributes: ['userId'],
where: {
userId: user.id
},
required: true
})
}
const podcastIncludes = []