diff --git a/api/src/controllers/shows/collections.ts b/api/src/controllers/shows/collections.ts index 4ba78d66..a845524a 100644 --- a/api/src/controllers/shows/collections.ts +++ b/api/src/controllers/shows/collections.ts @@ -21,7 +21,7 @@ import { processLanguages, } from "~/models/utils"; import { desc } from "~/models/utils/descriptions"; -import { getShow, getShows, showFilters, showSort } from "./logic"; +import { getShows, showFilters, showSort } from "./logic"; export const collections = new Elysia({ prefix: "/collections", @@ -41,11 +41,16 @@ export const collections = new Elysia({ set, }) => { const langs = processLanguages(languages); - const ret = await getShow(id, { + const [ret] = await getShows({ + limit: 1, + filter: and( + isUuid(id) ? eq(shows.id, id) : eq(shows.slug, id), + eq(shows.kind, "collection"), + ), languages: langs, + fallbackLanguage: langs.includes("*"), preferOriginal, relations, - filters: eq(shows.kind, "collection"), }); if (!ret) { return error(404, { @@ -60,7 +65,7 @@ export const collections = new Elysia({ }); } set.headers["content-language"] = ret.language; - return ret.show; + return ret; }, { detail: { diff --git a/api/src/controllers/shows/logic.ts b/api/src/controllers/shows/logic.ts index 695517b4..23eda8e7 100644 --- a/api/src/controllers/shows/logic.ts +++ b/api/src/controllers/shows/logic.ts @@ -143,7 +143,7 @@ export async function getShows({ languages: string[]; fallbackLanguage?: boolean; preferOriginal?: boolean; - relations?: ("translations" | "studios" | "videos")[]; + relations?: (keyof typeof showRelations)[]; }) { const transQ = db .selectDistinctOn([showTranslations.pk]) @@ -182,7 +182,7 @@ export async function getShows({ ...buildRelations(relations, showRelations, { languages }), }) .from(shows) - [fallbackLanguage ? "innerJoin" : "leftJoin"]( + [fallbackLanguage ? "innerJoin" : ("leftJoin" as "innerJoin")]( transQ, eq(shows.pk, transQ.pk), ) diff --git a/api/src/controllers/shows/series.ts b/api/src/controllers/shows/series.ts index 8af3a9d3..779ae39a 100644 --- a/api/src/controllers/shows/series.ts +++ b/api/src/controllers/shows/series.ts @@ -14,7 +14,7 @@ import { processLanguages, } from "~/models/utils"; import { desc } from "~/models/utils/descriptions"; -import { getShow, getShows, showFilters, showSort } from "./logic"; +import { getShows, showFilters, showSort } from "./logic"; export const series = new Elysia({ prefix: "/series", tags: ["series"] }) .model({ diff --git a/api/src/db/utils.ts b/api/src/db/utils.ts index fea4e8ef..baa3658c 100644 --- a/api/src/db/utils.ts +++ b/api/src/db/utils.ts @@ -106,7 +106,7 @@ export const jsonbObjectAgg = (key: SQLWrapper, value: SQL) => { }; export const jsonbAgg = (val: SQL) => { - return sql`jsonb_agg(${val})`; + return sql`jsonb_agg(${val})`; }; export const jsonbBuildObject = (select: Record) => { diff --git a/api/src/models/collections.ts b/api/src/models/collections.ts index 62a5c489..91f6f8df 100644 --- a/api/src/models/collections.ts +++ b/api/src/models/collections.ts @@ -7,6 +7,7 @@ import { Genre, Image, Language, + Original, Resource, SeedImage, TranslationRecord, @@ -27,14 +28,7 @@ const BaseCollection = t.Object({ descrpition: "Date of the last item of the collection", }), ), - originalLanguage: t.Nullable( - Language({ - description: "The language code this movie was made in.", - }), - ), - nextRefresh: t.String({ format: "date-time" }), - externalId: ExternalId(), }); @@ -56,6 +50,9 @@ export const Collection = t.Intersect([ CollectionTranslation, BaseCollection, DbMetadata, + t.Object({ + original: Original, + }), ]); export type Collection = Prettify; @@ -71,6 +68,9 @@ export const SeedCollection = t.Intersect([ t.Omit(BaseCollection, ["kind", "startAir", "endAir", "nextRefresh"]), t.Object({ slug: t.String({ format: "slug" }), + originalLanguage: Language({ + description: "The language code this collection's items were made in.", + }), translations: TranslationRecord( t.Intersect([ t.Omit(CollectionTranslation, [ @@ -84,6 +84,7 @@ export const SeedCollection = t.Intersect([ thumbnail: t.Nullable(SeedImage), banner: t.Nullable(SeedImage), logo: t.Nullable(SeedImage), + latinName: t.Optional(Original.properties.latinName), }), ]), ), diff --git a/api/src/models/movie.ts b/api/src/models/movie.ts index c64bcdef..dfd2bd3a 100644 --- a/api/src/models/movie.ts +++ b/api/src/models/movie.ts @@ -26,11 +26,8 @@ const BaseMovie = t.Object({ runtime: t.Nullable( t.Number({ minimum: 0, description: "Runtime of the movie in minutes." }), ), - airDate: t.Nullable(t.String({ format: "date" })), - nextRefresh: t.String({ format: "date-time" }), - externalId: ExternalId(), }); diff --git a/api/src/models/serie.ts b/api/src/models/serie.ts index 252e090e..00f6eb7c 100644 --- a/api/src/models/serie.ts +++ b/api/src/models/serie.ts @@ -35,12 +35,9 @@ const BaseSerie = t.Object({ description: "Average runtime of all episodes (in minutes.)", }), ), - startAir: t.Nullable(t.String({ format: "date" })), endAir: t.Nullable(t.String({ format: "date" })), - nextRefresh: t.String({ format: "date-time" }), - externalId: ExternalId(), });