Use original with collections too

This commit is contained in:
Zoe Roux
2025-03-09 16:46:04 +01:00
parent aab38f6a89
commit d61573668b
7 changed files with 21 additions and 21 deletions
+9 -4
View File
@@ -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: {
+2 -2
View File
@@ -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),
)
+1 -1
View File
@@ -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({