mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Test & fix entry video join
This commit is contained in:
parent
477fb24036
commit
70d0d480f6
@ -121,6 +121,7 @@ export const insertEntries = async (
|
|||||||
return {
|
return {
|
||||||
videoId: seed.video,
|
videoId: seed.video,
|
||||||
entryPk: retEntries[i].pk,
|
entryPk: retEntries[i].pk,
|
||||||
|
entrySlug: retEntries[i].slug,
|
||||||
needRendering: false,
|
needRendering: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -128,6 +129,7 @@ export const insertEntries = async (
|
|||||||
return seed.videos.map((x, j) => ({
|
return seed.videos.map((x, j) => ({
|
||||||
videoId: x,
|
videoId: x,
|
||||||
entryPk: retEntries[i].pk,
|
entryPk: retEntries[i].pk,
|
||||||
|
entrySlug: retEntries[i].slug,
|
||||||
// The first video should not have a rendering.
|
// The first video should not have a rendering.
|
||||||
needRendering: j && seed.videos!.length > 1,
|
needRendering: j && seed.videos!.length > 1,
|
||||||
}));
|
}));
|
||||||
@ -142,9 +144,9 @@ export const insertEntries = async (
|
|||||||
db
|
db
|
||||||
.select({
|
.select({
|
||||||
entryPk: sql<number>`vids.entryPk::integer`.as("entry"),
|
entryPk: sql<number>`vids.entryPk::integer`.as("entry"),
|
||||||
videoPk: sql`${videos.pk}`.as("video"),
|
videoPk: videos.pk,
|
||||||
slug: computeVideoSlug(
|
slug: computeVideoSlug(
|
||||||
sql`${show.slug}::text`,
|
sql`vids.entrySlug::text`,
|
||||||
sql`vids.needRendering::boolean`,
|
sql`vids.needRendering::boolean`,
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
@ -7,8 +7,11 @@ import { processOptImage } from "../images";
|
|||||||
type StudioI = typeof studios.$inferInsert;
|
type StudioI = typeof studios.$inferInsert;
|
||||||
type StudioTransI = typeof studioTranslations.$inferInsert;
|
type StudioTransI = typeof studioTranslations.$inferInsert;
|
||||||
|
|
||||||
export const insertStudios = async (seed: SeedStudio[], showPk: number) => {
|
export const insertStudios = async (
|
||||||
if (!seed.length) return [];
|
seed: SeedStudio[] | undefined,
|
||||||
|
showPk: number,
|
||||||
|
) => {
|
||||||
|
if (!seed?.length) return [];
|
||||||
|
|
||||||
return await db.transaction(async (tx) => {
|
return await db.transaction(async (tx) => {
|
||||||
const vals: StudioI[] = seed.map((x) => {
|
const vals: StudioI[] = seed.map((x) => {
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
SeedImage,
|
SeedImage,
|
||||||
TranslationRecord,
|
TranslationRecord,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
import { Video } from "../video";
|
||||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||||
|
|
||||||
export const BaseEpisode = t.Intersect([
|
export const BaseEpisode = t.Intersect([
|
||||||
@ -25,6 +26,9 @@ export const Episode = t.Intersect([
|
|||||||
Resource(),
|
Resource(),
|
||||||
EntryTranslation(),
|
EntryTranslation(),
|
||||||
BaseEpisode,
|
BaseEpisode,
|
||||||
|
t.Object({
|
||||||
|
videos: t.Optional(t.Array(Video)),
|
||||||
|
}),
|
||||||
DbMetadata,
|
DbMetadata,
|
||||||
]);
|
]);
|
||||||
export type Episode = Prettify<typeof Episode.static>;
|
export type Episode = Prettify<typeof Episode.static>;
|
||||||
@ -34,7 +38,7 @@ export const SeedEpisode = t.Intersect([
|
|||||||
t.Object({
|
t.Object({
|
||||||
thumbnail: t.Nullable(SeedImage),
|
thumbnail: t.Nullable(SeedImage),
|
||||||
translations: TranslationRecord(EntryTranslation()),
|
translations: TranslationRecord(EntryTranslation()),
|
||||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
videos: t.Optional(t.Array(t.String({ format: "uuid" }), { default: [] })),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
export type SeedEpisode = Prettify<typeof SeedEpisode.static>;
|
export type SeedEpisode = Prettify<typeof SeedEpisode.static>;
|
||||||
@ -45,4 +49,5 @@ registerExamples(Episode, {
|
|||||||
...ep.translations.en,
|
...ep.translations.en,
|
||||||
...bubbleImages,
|
...bubbleImages,
|
||||||
slug: `${madeInAbyss.slug}-s${ep.seasonNumber}-e${ep.episodeNumber}`,
|
slug: `${madeInAbyss.slug}-s${ep.seasonNumber}-e${ep.episodeNumber}`,
|
||||||
|
videos: [],
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ import { type Prettify, comment } from "~/utils";
|
|||||||
import { madeInAbyss, registerExamples } from "../examples";
|
import { madeInAbyss, registerExamples } from "../examples";
|
||||||
import { DbMetadata, SeedImage } from "../utils";
|
import { DbMetadata, SeedImage } from "../utils";
|
||||||
import { Resource } from "../utils/resource";
|
import { Resource } from "../utils/resource";
|
||||||
|
import { Video } from "../video";
|
||||||
import { BaseEntry } from "./base-entry";
|
import { BaseEntry } from "./base-entry";
|
||||||
|
|
||||||
export const ExtraType = t.UnionEnum([
|
export const ExtraType = t.UnionEnum([
|
||||||
@ -31,7 +32,14 @@ export const BaseExtra = t.Intersect(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Extra = t.Intersect([Resource(), BaseExtra, DbMetadata]);
|
export const Extra = t.Intersect([
|
||||||
|
Resource(),
|
||||||
|
BaseExtra,
|
||||||
|
t.Object({
|
||||||
|
video: t.Optional(Video),
|
||||||
|
}),
|
||||||
|
DbMetadata,
|
||||||
|
]);
|
||||||
export type Extra = Prettify<typeof Extra.static>;
|
export type Extra = Prettify<typeof Extra.static>;
|
||||||
|
|
||||||
export const SeedExtra = t.Intersect([
|
export const SeedExtra = t.Intersect([
|
||||||
@ -44,4 +52,4 @@ export const SeedExtra = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type SeedExtra = Prettify<typeof SeedExtra.static>;
|
export type SeedExtra = Prettify<typeof SeedExtra.static>;
|
||||||
|
|
||||||
registerExamples(Extra, madeInAbyss.extras[0]);
|
registerExamples(Extra, { ...madeInAbyss.extras[0], video: undefined });
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
SeedImage,
|
SeedImage,
|
||||||
TranslationRecord,
|
TranslationRecord,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
import { Video } from "../video";
|
||||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||||
|
|
||||||
export const BaseMovieEntry = t.Intersect(
|
export const BaseMovieEntry = t.Intersect(
|
||||||
@ -43,6 +44,9 @@ export const MovieEntry = t.Intersect([
|
|||||||
Resource(),
|
Resource(),
|
||||||
MovieEntryTranslation,
|
MovieEntryTranslation,
|
||||||
BaseMovieEntry,
|
BaseMovieEntry,
|
||||||
|
t.Object({
|
||||||
|
videos: t.Optional(t.Array(Video)),
|
||||||
|
}),
|
||||||
DbMetadata,
|
DbMetadata,
|
||||||
]);
|
]);
|
||||||
export type MovieEntry = Prettify<typeof MovieEntry.static>;
|
export type MovieEntry = Prettify<typeof MovieEntry.static>;
|
||||||
@ -58,7 +62,7 @@ export const SeedMovieEntry = t.Intersect([
|
|||||||
t.Object({ poster: t.Nullable(SeedImage) }),
|
t.Object({ poster: t.Nullable(SeedImage) }),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
videos: t.Optional(t.Array(t.String({ format: "uuid" }), { default: [] })),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
export type SeedMovieEntry = Prettify<typeof SeedMovieEntry.static>;
|
export type SeedMovieEntry = Prettify<typeof SeedMovieEntry.static>;
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
SeedImage,
|
SeedImage,
|
||||||
TranslationRecord,
|
TranslationRecord,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
import { Video } from "../video";
|
||||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||||
|
|
||||||
export const BaseSpecial = t.Intersect(
|
export const BaseSpecial = t.Intersect(
|
||||||
@ -35,6 +36,9 @@ export const Special = t.Intersect([
|
|||||||
Resource(),
|
Resource(),
|
||||||
EntryTranslation(),
|
EntryTranslation(),
|
||||||
BaseSpecial,
|
BaseSpecial,
|
||||||
|
t.Object({
|
||||||
|
videos: t.Optional(t.Array(Video)),
|
||||||
|
}),
|
||||||
DbMetadata,
|
DbMetadata,
|
||||||
]);
|
]);
|
||||||
export type Special = Prettify<typeof Special.static>;
|
export type Special = Prettify<typeof Special.static>;
|
||||||
@ -44,7 +48,7 @@ export const SeedSpecial = t.Intersect([
|
|||||||
t.Object({
|
t.Object({
|
||||||
thumbnail: t.Nullable(SeedImage),
|
thumbnail: t.Nullable(SeedImage),
|
||||||
translations: TranslationRecord(EntryTranslation()),
|
translations: TranslationRecord(EntryTranslation()),
|
||||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
videos: t.Optional(t.Array(t.String({ format: "uuid" }), { default: [] })),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
export type SeedSpecial = Prettify<typeof SeedSpecial.static>;
|
export type SeedSpecial = Prettify<typeof SeedSpecial.static>;
|
||||||
|
@ -3,15 +3,15 @@ import type { Video } from "~/models/video";
|
|||||||
|
|
||||||
export const madeInAbyssVideo: Video = {
|
export const madeInAbyssVideo: Video = {
|
||||||
id: "3cd436ee-01ff-4f45-ba98-654282531234",
|
id: "3cd436ee-01ff-4f45-ba98-654282531234",
|
||||||
slug: "made-in-abyss-s1e1",
|
slug: "made-in-abyss-s1e13",
|
||||||
path: "/video/Made in abyss S01E01.mkv",
|
path: "/video/Made in abyss S01E13.mkv",
|
||||||
rendering: "459429fa062adeebedcc2bb04b9965de0262bfa453369783132d261be79021bd",
|
rendering: "459429fa062adeebedcc2bb04b9965de0262bfa453369783132d261be79021bd",
|
||||||
part: null,
|
part: null,
|
||||||
version: 1,
|
version: 1,
|
||||||
guess: {
|
guess: {
|
||||||
title: "Made in abyss",
|
title: "Made in abyss",
|
||||||
season: [1],
|
season: [1],
|
||||||
episode: [1],
|
episode: [13],
|
||||||
type: "episode",
|
type: "episode",
|
||||||
from: "guessit",
|
from: "guessit",
|
||||||
},
|
},
|
||||||
@ -156,6 +156,7 @@ export const madeInAbyss = {
|
|||||||
link: "https://www.themoviedb.org/tv/72636/season/1/episode/13",
|
link: "https://www.themoviedb.org/tv/72636/season/1/episode/13",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
videos: [madeInAbyssVideo.id],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: "special",
|
kind: "special",
|
||||||
@ -240,7 +241,7 @@ export const madeInAbyss = {
|
|||||||
name: "The Making of MADE IN ABYSS 01",
|
name: "The Making of MADE IN ABYSS 01",
|
||||||
runtime: 17,
|
runtime: 17,
|
||||||
thumbnail: null,
|
thumbnail: null,
|
||||||
video: "3cd436ee-01ff-4f45-ba98-654282531234",
|
video: madeInAbyssVideo.id,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
studios: [
|
studios: [
|
||||||
|
@ -88,9 +88,9 @@ export const SeedMovie = t.Intersect([
|
|||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
videos: t.Optional(t.Array(t.String({ format: "uuid" }), { default: [] })),
|
||||||
collection: t.Optional(SeedCollection),
|
collection: t.Optional(SeedCollection),
|
||||||
studios: t.Array(SeedStudio),
|
studios: t.Optional(t.Array(SeedStudio, { default: [] })),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
export type SeedMovie = Prettify<typeof SeedMovie.static>;
|
export type SeedMovie = Prettify<typeof SeedMovie.static>;
|
||||||
|
@ -98,9 +98,9 @@ export const SeedSerie = t.Intersect([
|
|||||||
),
|
),
|
||||||
seasons: t.Array(SeedSeason),
|
seasons: t.Array(SeedSeason),
|
||||||
entries: t.Array(SeedEntry),
|
entries: t.Array(SeedEntry),
|
||||||
extras: t.Optional(t.Array(SeedExtra)),
|
extras: t.Optional(t.Array(SeedExtra, { default: [] })),
|
||||||
collection: t.Optional(SeedCollection),
|
collection: t.Optional(SeedCollection),
|
||||||
studios: t.Array(SeedStudio),
|
studios: t.Optional(t.Array(SeedStudio, { default: [] })),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
export type SeedSerie = typeof SeedSerie.static;
|
export type SeedSerie = typeof SeedSerie.static;
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import { beforeAll, describe, expect, it } from "bun:test";
|
import { beforeAll, describe, expect, it } from "bun:test";
|
||||||
import { getEntries, getExtras, getUnknowns } from "tests/helpers";
|
import { createSerie, createVideo, getEntries, getExtras } from "tests/helpers";
|
||||||
import { expectStatus } from "tests/utils";
|
import { expectStatus } from "tests/utils";
|
||||||
import { seedSerie } from "~/controllers/seed/series";
|
import { db } from "~/db";
|
||||||
import { madeInAbyss } from "~/models/examples";
|
import { shows, videos } from "~/db/schema";
|
||||||
|
import { madeInAbyss, madeInAbyssVideo } from "~/models/examples";
|
||||||
let miaId = "";
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const ret = await seedSerie(madeInAbyss);
|
await db.delete(shows);
|
||||||
if (!("status" in ret)) miaId = ret.id;
|
await db.delete(videos);
|
||||||
|
console.log(await createVideo(madeInAbyssVideo));
|
||||||
|
await createSerie(madeInAbyss);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Get entries", () => {
|
describe("Get entries", () => {
|
||||||
@ -27,6 +28,12 @@ describe("Get entries", () => {
|
|||||||
expectStatus(resp, body).toBe(200);
|
expectStatus(resp, body).toBe(200);
|
||||||
expect(body.items).toBeArrayOfSize(madeInAbyss.entries.length);
|
expect(body.items).toBeArrayOfSize(madeInAbyss.entries.length);
|
||||||
});
|
});
|
||||||
|
it("With videos", async () => {
|
||||||
|
const [resp, body] = await getEntries(madeInAbyss.slug, { langs: "en" });
|
||||||
|
|
||||||
|
expectStatus(resp, body).toBe(200);
|
||||||
|
expect(body.items[0].videos).toBeArrayOfSize(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Get extra", () => {
|
describe("Get extra", () => {
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
import { beforeAll, describe, expect, it } from "bun:test";
|
import { beforeAll, describe, expect, it } from "bun:test";
|
||||||
import { getSeasons } from "tests/helpers";
|
import { createSerie, getSeasons } from "tests/helpers";
|
||||||
import { expectStatus } from "tests/utils";
|
import { expectStatus } from "tests/utils";
|
||||||
import { seedSerie } from "~/controllers/seed/series";
|
|
||||||
import { madeInAbyss } from "~/models/examples";
|
import { madeInAbyss } from "~/models/examples";
|
||||||
|
|
||||||
let miaId = "";
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const ret = await seedSerie(madeInAbyss);
|
await createSerie(madeInAbyss);
|
||||||
if (!("status" in ret)) miaId = ret.id;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Get seasons", () => {
|
describe("Get seasons", () => {
|
||||||
|
@ -25,7 +25,12 @@ describe("Serie seeding", () => {
|
|||||||
where: eq(shows.id, body.id),
|
where: eq(shows.id, body.id),
|
||||||
with: {
|
with: {
|
||||||
seasons: { orderBy: seasons.seasonNumber },
|
seasons: { orderBy: seasons.seasonNumber },
|
||||||
entries: { with: { translations: true } },
|
entries: {
|
||||||
|
with: {
|
||||||
|
translations: true,
|
||||||
|
evj: { with: { video: true } },
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,7 +42,9 @@ describe("Serie seeding", () => {
|
|||||||
madeInAbyss.entries.length + madeInAbyss.extras.length,
|
madeInAbyss.entries.length + madeInAbyss.extras.length,
|
||||||
);
|
);
|
||||||
|
|
||||||
const ep13 = madeInAbyss.entries.find((x) => x.order === 13)!;
|
const { videos: _, ...ep13 } = madeInAbyss.entries.find(
|
||||||
|
(x) => x.order === 13,
|
||||||
|
)!;
|
||||||
expect(ret!.entries.find((x) => x.order === 13)).toMatchObject({
|
expect(ret!.entries.find((x) => x.order === 13)).toMatchObject({
|
||||||
...ep13,
|
...ep13,
|
||||||
slug: "made-in-abyss-s1e13",
|
slug: "made-in-abyss-s1e13",
|
||||||
@ -48,6 +55,12 @@ describe("Serie seeding", () => {
|
|||||||
...ep13.translations.en,
|
...ep13.translations.en,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
evj: [
|
||||||
|
expect.objectContaining({
|
||||||
|
slug: madeInAbyssVideo.slug,
|
||||||
|
video: expect.objectContaining({ path: madeInAbyssVideo.path }),
|
||||||
|
}),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { number, ...special } = madeInAbyss.entries.find(
|
const { number, ...special } = madeInAbyss.entries.find(
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { beforeAll, describe, expect, it } from "bun:test";
|
import { beforeAll, describe, expect, it } from "bun:test";
|
||||||
import { getSerie, getShowsByStudio, getStudio } from "tests/helpers";
|
import { createSerie, getSerie, getShowsByStudio, getStudio } from "tests/helpers";
|
||||||
import { expectStatus } from "tests/utils";
|
import { expectStatus } from "tests/utils";
|
||||||
import { seedSerie } from "~/controllers/seed/series";
|
|
||||||
import { madeInAbyss } from "~/models/examples";
|
import { madeInAbyss } from "~/models/examples";
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await seedSerie(madeInAbyss);
|
await createSerie(madeInAbyss);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Get by studio", () => {
|
describe("Get by studio", () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user