mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-06-08 05:51:01 +00:00
Allow insert without original translation
This commit is contained in:
@@ -30,8 +30,8 @@ export type ImageTask = {
|
||||
export const enqueueOptImage = (
|
||||
imgQueue: ImageTask[],
|
||||
img:
|
||||
| { url: string | null; column: PgColumn }
|
||||
| { url: string | null; table: PgTable; column: SQL },
|
||||
| { url?: string | null; column: PgColumn }
|
||||
| { url?: string | null; table: PgTable; column: SQL },
|
||||
): Image | null => {
|
||||
if (!img.url) return null;
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ export const insertShow = record(
|
||||
async (
|
||||
show: Omit<Show, "original">,
|
||||
original: Original & {
|
||||
poster: string | null;
|
||||
thumbnail: string | null;
|
||||
banner: string | null;
|
||||
logo: string | null;
|
||||
poster?: string | null;
|
||||
thumbnail?: string | null;
|
||||
banner?: string | null;
|
||||
logo?: string | null;
|
||||
},
|
||||
translations:
|
||||
| SeedMovie["translations"]
|
||||
|
||||
@@ -55,20 +55,13 @@ export const seedMovie = async (
|
||||
const { translations, videos, collection, studios, staff, ...movie } = seed;
|
||||
const nextRefresh = guessNextRefresh(movie.airDate ?? new Date());
|
||||
|
||||
const original = translations[movie.originalLanguage];
|
||||
if (!original) {
|
||||
return {
|
||||
status: 422,
|
||||
message: "No translation available in the original language.",
|
||||
};
|
||||
}
|
||||
|
||||
const col = await insertCollection(collection, {
|
||||
kind: "movie",
|
||||
nextRefresh,
|
||||
...seed,
|
||||
});
|
||||
|
||||
const original = translations[movie.originalLanguage];
|
||||
const show = await insertShow(
|
||||
{
|
||||
kind: "movie",
|
||||
@@ -78,11 +71,17 @@ export const seedMovie = async (
|
||||
entriesCount: 1,
|
||||
...movie,
|
||||
},
|
||||
{
|
||||
...original,
|
||||
latinName: original.latinName ?? null,
|
||||
language: movie.originalLanguage,
|
||||
},
|
||||
original
|
||||
? {
|
||||
...original,
|
||||
latinName: original.latinName ?? null,
|
||||
language: movie.originalLanguage,
|
||||
}
|
||||
: {
|
||||
name: null,
|
||||
latinName: null,
|
||||
language: movie.originalLanguage,
|
||||
},
|
||||
translations,
|
||||
);
|
||||
if ("status" in show) return show;
|
||||
|
||||
@@ -91,20 +91,13 @@ export const seedSerie = async (
|
||||
} = seed;
|
||||
const nextRefresh = guessNextRefresh(serie.startAir ?? new Date());
|
||||
|
||||
const original = translations[serie.originalLanguage];
|
||||
if (!original) {
|
||||
return {
|
||||
status: 422,
|
||||
message: "No translation available in the original language.",
|
||||
};
|
||||
}
|
||||
|
||||
const col = await insertCollection(collection, {
|
||||
kind: "serie",
|
||||
nextRefresh,
|
||||
...seed,
|
||||
});
|
||||
|
||||
const original = translations[serie.originalLanguage];
|
||||
const show = await insertShow(
|
||||
{
|
||||
kind: "serie",
|
||||
@@ -113,11 +106,17 @@ export const seedSerie = async (
|
||||
entriesCount: entries.length,
|
||||
...serie,
|
||||
},
|
||||
{
|
||||
...original,
|
||||
latinName: original.latinName ?? null,
|
||||
language: serie.originalLanguage,
|
||||
},
|
||||
original
|
||||
? {
|
||||
...original,
|
||||
latinName: original.latinName ?? null,
|
||||
language: serie.originalLanguage,
|
||||
}
|
||||
: {
|
||||
name: null,
|
||||
latinName: null,
|
||||
language: serie.originalLanguage,
|
||||
},
|
||||
translations,
|
||||
);
|
||||
if ("status" in show) return show;
|
||||
|
||||
@@ -7,10 +7,12 @@ export const Original = t.Object({
|
||||
description: "The language code this was made in.",
|
||||
examples: ["ja"],
|
||||
}),
|
||||
name: t.String({
|
||||
description: "The name in the original language",
|
||||
examples: ["進撃の巨人"],
|
||||
}),
|
||||
name: t.Nullable(
|
||||
t.String({
|
||||
description: "The name in the original language",
|
||||
examples: ["進撃の巨人"],
|
||||
}),
|
||||
),
|
||||
latinName: t.Nullable(
|
||||
t.String({
|
||||
description: comment`
|
||||
|
||||
@@ -6,9 +6,12 @@ import {
|
||||
getStaffRoles,
|
||||
} from "tests/helpers";
|
||||
import { expectStatus } from "tests/utils";
|
||||
import { db } from "~/db";
|
||||
import { staff } from "~/db/schema";
|
||||
import { madeInAbyss } from "~/models/examples";
|
||||
|
||||
beforeAll(async () => {
|
||||
await db.delete(staff);
|
||||
await createSerie(madeInAbyss);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { expectStatus } from "tests/utils";
|
||||
import { db } from "~/db";
|
||||
import { seasons, shows, videos } from "~/db/schema";
|
||||
import { entries, seasons, shows, videos } from "~/db/schema";
|
||||
import { madeInAbyss, madeInAbyssVideo } from "~/models/examples";
|
||||
import { createSerie } from "../helpers";
|
||||
|
||||
@@ -106,6 +106,7 @@ describe("Serie seeding", () => {
|
||||
});
|
||||
|
||||
it("Can create a serie with quotes", async () => {
|
||||
await db.delete(entries);
|
||||
const [resp, body] = await createSerie({
|
||||
...madeInAbyss,
|
||||
slug: "quote-test",
|
||||
|
||||
Reference in New Issue
Block a user