Skip to content

Commit

Permalink
fix genre and query filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfagun74 committed Oct 19, 2023
1 parent 76deb0e commit d82fb9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/modules/games/games.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,20 @@ export class GamesController {
})
@MinimumRole(Role.GUEST)
async get(@Paginate() query: PaginateQuery): Promise<Paginated<Game>> {
const relations = ["box_image"];
if (query.filter["genres.name"]) {
relations.push("genres");
}
if (query.filter["tags.name"]) {
relations.push("tags");
}

return paginate(query, this.gamesRepository, {
paginationType: PaginationType.TAKE_AND_SKIP,
defaultLimit: 100,
maxLimit: NO_PAGINATION,
nullSort: "last",
relations: ["box_image"],
relations,
sortableColumns: [
"id",
"title",
Expand All @@ -96,6 +104,8 @@ export class GamesController {
average_playtime: all_filters,
early_access: all_filters,
type: all_filters,
"genres.name": all_filters,
"tags.name": all_filters,
},
withDeleted: false,
});
Expand Down
2 changes: 1 addition & 1 deletion src/modules/tags/tags.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class TagsController {
async getTags(@Paginate() query: PaginateQuery): Promise<Paginated<Tag>> {
const paginatedResults = await paginate(query, this.tagRepository, {
paginationType: PaginationType.TAKE_AND_SKIP,
defaultLimit: Number.MAX_SAFE_INTEGER,
defaultLimit: 100,
maxLimit: NO_PAGINATION,
nullSort: "last",
relations: ["games"],
Expand Down

0 comments on commit d82fb9d

Please sign in to comment.