From 10ac7e1ec6673a1e2ed3612bf4f9a7609e6b9893 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 6 Dec 2025 00:47:45 +0100 Subject: [PATCH 1/2] Handle duplicated studios --- api/src/controllers/seed/insert/studios.ts | 2 ++ api/src/utils.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/src/controllers/seed/insert/studios.ts b/api/src/controllers/seed/insert/studios.ts index 2906aeb8..dfffb016 100644 --- a/api/src/controllers/seed/insert/studios.ts +++ b/api/src/controllers/seed/insert/studios.ts @@ -4,6 +4,7 @@ import { showStudioJoin, studios, studioTranslations } from "~/db/schema"; import { conflictUpdateAllExcept, sqlarr, unnestValues } from "~/db/utils"; import type { SeedStudio } from "~/models/studio"; import { record } from "~/otel"; +import { uniqBy } from "~/utils"; import { enqueueOptImage, flushImageQueue, type ImageTask } from "../images"; type StudioI = typeof studios.$inferInsert; @@ -15,6 +16,7 @@ export const insertStudios = record( if (!seed?.length) return []; return await db.transaction(async (tx) => { + seed = uniqBy(seed!, (x) => x.slug); const vals: StudioI[] = seed.map((x) => { const { translations, ...item } = x; return item; diff --git a/api/src/utils.ts b/api/src/utils.ts index da16412f..c74bd4a9 100644 --- a/api/src/utils.ts +++ b/api/src/utils.ts @@ -29,7 +29,7 @@ export function getFile(path: string): BunFile | S3File { return Bun.file(path); } -export function uniqBy(a: T[], key: (val: T) => string) { +export function uniqBy(a: T[], key: (val: T) => string): T[] { const seen: Record = {}; return a.filter((item) => { const k = key(item); From c839fc826e14fdf8d04239e1078bb4190f87adbe Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 6 Dec 2025 00:47:53 +0100 Subject: [PATCH 2/2] Fix front type for original --- front/src/models/collection.ts | 2 +- front/src/models/movie.ts | 2 +- front/src/models/serie.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/src/models/collection.ts b/front/src/models/collection.ts index c1d7448a..4fbb652f 100644 --- a/front/src/models/collection.ts +++ b/front/src/models/collection.ts @@ -10,7 +10,7 @@ export const Collection = z slug: z.string(), name: z.string(), original: z.object({ - name: z.string(), + name: z.string().nullable(), latinName: z.string().nullable(), language: z.string(), }), diff --git a/front/src/models/movie.ts b/front/src/models/movie.ts index ab0b2631..8b00b1cc 100644 --- a/front/src/models/movie.ts +++ b/front/src/models/movie.ts @@ -11,7 +11,7 @@ export const Movie = z slug: z.string(), name: z.string(), original: z.object({ - name: z.string(), + name: z.string().nullable(), latinName: z.string().nullable(), language: z.string(), }), diff --git a/front/src/models/serie.ts b/front/src/models/serie.ts index f947388d..f4a12468 100644 --- a/front/src/models/serie.ts +++ b/front/src/models/serie.ts @@ -12,7 +12,7 @@ export const Serie = z slug: z.string(), name: z.string(), original: z.object({ - name: z.string(), + name: z.string().nullable(), latinName: z.string().nullable(), language: z.string(), }),