From aa5ba7f2a90aa6158918855faea88dc9abda796d Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 22 Jun 2025 19:28:26 +0200 Subject: [PATCH] Allow `/api/shows` to be filtered by `kind` --- api/src/controllers/shows/logic.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/api/src/controllers/shows/logic.ts b/api/src/controllers/shows/logic.ts index 7f166858..7a1ceebf 100644 --- a/api/src/controllers/shows/logic.ts +++ b/api/src/controllers/shows/logic.ts @@ -1,4 +1,4 @@ -import { type SQL, and, eq, exists, gt, ne, sql } from "drizzle-orm"; +import { and, eq, exists, gt, ne, type SQL, sql } from "drizzle-orm"; import { db } from "~/db"; import { entries, @@ -6,10 +6,10 @@ import { entryVideoJoin, profiles, showStudioJoin, - showTranslations, shows, - studioTranslations, + showTranslations, studios, + studioTranslations, videos, } from "~/db/schema"; import { watchlist } from "~/db/schema/watchlist"; @@ -26,12 +26,12 @@ import type { MovieStatus } from "~/models/movie"; import { SerieStatus, type SerieTranslation } from "~/models/serie"; import type { Studio } from "~/models/studio"; import { + buildRelations, type FilterDef, Genre, type Image, - Sort, - buildRelations, keysetPaginate, + Sort, sortToSql, } from "~/models/utils"; import type { EmbeddedVideo } from "~/models/video"; @@ -49,6 +49,11 @@ export const watchStatusQ = db .as("watchstatus"); export const showFilters: FilterDef = { + kind: { + column: shows.kind, + type: "enum", + values: ["serie", "movie", "collection"], + }, genres: { column: shows.genres, type: "enum",