mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-27 01:22:30 -04:00
Add ?with=studios in movies & series
This commit is contained in:
@@ -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>;
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user