Skip to content

Commit

Permalink
Support for virtual UNPLAYED state.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfagun74 committed Oct 25, 2024
1 parent 3d6f527 commit e8e0982
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/modules/games/games.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,27 @@ export class GamesController {
relations.push("metadata.tags");
}

if (
query.filter?.["progresses"] ||
query.filter?.["progresses.state"] ||
query.filter?.["progresses.user.id"]
) {
const progressesFilter = query.filter?.["progresses.state"];
const progressesUserFilter = query.filter?.["progresses.user.id"];
if (progressesFilter || progressesUserFilter) {
// Support for virtual UNPLAYED state.
if (progressesFilter?.includes("UNPLAYED")) {
if (progressesFilter) {
query.filter["progresses.state"] = [
"$null",
`$or:${progressesFilter}`,
];
}

if (progressesUserFilter) {
query.filter["progresses.user.id"] = [
"$null",
`$or:$not:${progressesUserFilter}`,
`$or:$eq:${progressesUserFilter}`,
];
}
}

relations.push("progresses", "progresses.user");
}

Expand Down Expand Up @@ -154,7 +170,6 @@ export class GamesController {
"metadata.genres.name": true,
"metadata.tags.name": true,
"metadata.age_rating": true,
progresses: true,
"progresses.state": true,
"progresses.user.id": true,
},
Expand Down

0 comments on commit e8e0982

Please sign in to comment.