Add ?with=studios in movies & series

This commit is contained in:
Zoe Roux
2025-03-03 16:15:56 +01:00
parent 6cf8947c80
commit 750434465d
17 changed files with 1461 additions and 140 deletions
+2 -1
View File
@@ -2,7 +2,7 @@ import { t } from "elysia";
import type { Prettify } from "~/utils";
import { SeedCollection } from "./collections";
import { bubble, bubbleImages, registerExamples } from "./examples";
import { SeedStudio } from "./studio";
import { SeedStudio, Studio } from "./studio";
import {
DbMetadata,
ExternalId,
@@ -68,6 +68,7 @@ export const FullMovie = t.Intersect([
t.Object({
translations: t.Optional(TranslationRecord(MovieTranslation)),
videos: t.Optional(t.Array(Video)),
studios: t.Optional(t.Array(Studio)),
}),
]);
export type FullMovie = Prettify<typeof FullMovie.static>;
+2 -1
View File
@@ -4,7 +4,7 @@ import { SeedCollection } from "./collections";
import { SeedEntry, SeedExtra } from "./entry";
import { bubbleImages, madeInAbyss, registerExamples } from "./examples";
import { SeedSeason } from "./season";
import { SeedStudio } from "./studio";
import { SeedStudio, Studio } from "./studio";
import {
DbMetadata,
ExternalId,
@@ -76,6 +76,7 @@ export const FullSerie = t.Intersect([
Serie,
t.Object({
translations: t.Optional(TranslationRecord(SerieTranslation)),
studios: t.Optional(t.Array(Studio)),
}),
]);
export type FullMovie = Prettify<typeof FullSerie.static>;
+18
View File
@@ -4,7 +4,9 @@ import {
type TSchema,
type TString,
} from "@sinclair/typebox";
import { type Column, type Table, eq, sql } from "drizzle-orm";
import { t } from "elysia";
import { sqlarr } from "~/db/utils";
import { comment } from "../../utils";
import { KErrorT } from "../error";
@@ -106,3 +108,19 @@ export const AcceptLanguage = ({
`
: ""),
});
export const selectTranslationQuery = (
translationTable: Table & { language: Column },
languages: string[],
) => ({
columns: {
pk: false,
} as const,
where: !languages.includes("*")
? eq(translationTable.language, sql`any(${sqlarr(languages)})`)
: undefined,
orderBy: [
sql`array_position(${sqlarr(languages)}, ${translationTable.language})`,
],
limit: 1,
});