mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Add back isAvailable
for movies
This commit is contained in:
parent
bbbf7b32e0
commit
269003c25d
@ -88,6 +88,7 @@ export async function getShows({
|
|||||||
status: sql<MovieStatus>`${shows.status}`,
|
status: sql<MovieStatus>`${shows.status}`,
|
||||||
airDate: shows.startAir,
|
airDate: shows.startAir,
|
||||||
kind: sql<any>`${shows.kind}`,
|
kind: sql<any>`${shows.kind}`,
|
||||||
|
isAvailable: sql<boolean>`${shows.availableCount} != 0`,
|
||||||
|
|
||||||
poster: sql<Image>`coalesce(${showTranslations.poster}, ${poster})`,
|
poster: sql<Image>`coalesce(${showTranslations.poster}, ${poster})`,
|
||||||
thumbnail: sql<Image>`coalesce(${showTranslations.thumbnail}, ${thumbnail})`,
|
thumbnail: sql<Image>`coalesce(${showTranslations.thumbnail}, ${thumbnail})`,
|
||||||
@ -138,6 +139,7 @@ export async function getShow(
|
|||||||
extras: {
|
extras: {
|
||||||
airDate: sql<string>`${shows.startAir}`.as("airDate"),
|
airDate: sql<string>`${shows.startAir}`.as("airDate"),
|
||||||
status: sql<MovieStatus>`${shows.status}`.as("status"),
|
status: sql<MovieStatus>`${shows.status}`.as("status"),
|
||||||
|
isAvailable: sql<boolean>`${shows.availableCount} != 0`.as("isAvailable"),
|
||||||
},
|
},
|
||||||
where: and(isUuid(id) ? eq(shows.id, id) : eq(shows.slug, id), filters),
|
where: and(isUuid(id) ? eq(shows.id, id) : eq(shows.slug, id), filters),
|
||||||
with: {
|
with: {
|
||||||
|
@ -59,7 +59,9 @@ export const Movie = t.Intersect([
|
|||||||
MovieTranslation,
|
MovieTranslation,
|
||||||
BaseMovie,
|
BaseMovie,
|
||||||
DbMetadata,
|
DbMetadata,
|
||||||
// t.Object({ isAvailable: t.Boolean() }),
|
t.Object({
|
||||||
|
isAvailable: t.Boolean(),
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
export type Movie = Prettify<typeof Movie.static>;
|
export type Movie = Prettify<typeof Movie.static>;
|
||||||
|
|
||||||
|
@ -2,14 +2,15 @@ import { beforeAll, describe, expect, it } from "bun:test";
|
|||||||
import { expectStatus } from "tests/utils";
|
import { expectStatus } from "tests/utils";
|
||||||
import { seedMovie } from "~/controllers/seed/movies";
|
import { seedMovie } from "~/controllers/seed/movies";
|
||||||
import { db } from "~/db";
|
import { db } from "~/db";
|
||||||
import { shows } from "~/db/schema";
|
import { shows, videos } from "~/db/schema";
|
||||||
import { bubble } from "~/models/examples";
|
import { bubble, bubbleVideo } from "~/models/examples";
|
||||||
import { getMovie } from "../helpers";
|
import { getMovie } from "../helpers";
|
||||||
|
|
||||||
let bubbleId = "";
|
let bubbleId = "";
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await db.delete(shows);
|
await db.delete(shows);
|
||||||
|
await db.insert(videos).values(bubbleVideo);
|
||||||
const ret = await seedMovie(bubble);
|
const ret = await seedMovie(bubble);
|
||||||
if (!("status" in ret)) bubbleId = ret.id;
|
if (!("status" in ret)) bubbleId = ret.id;
|
||||||
});
|
});
|
||||||
@ -116,4 +117,21 @@ describe("Get movie", () => {
|
|||||||
});
|
});
|
||||||
expect(resp.headers.get("Content-Language")).toBe("en");
|
expect(resp.headers.get("Content-Language")).toBe("en");
|
||||||
});
|
});
|
||||||
|
it("With isAvailable", async () => {
|
||||||
|
const [resp, body] = await getMovie(bubble.slug, {});
|
||||||
|
|
||||||
|
expectStatus(resp, body).toBe(200);
|
||||||
|
expect(body.isAvailable).toBe(true);
|
||||||
|
});
|
||||||
|
it("With isAvailable=false", async () => {
|
||||||
|
await seedMovie({
|
||||||
|
...bubble,
|
||||||
|
slug: "no-video",
|
||||||
|
videos: [],
|
||||||
|
});
|
||||||
|
const [resp, body] = await getMovie("no-video", {});
|
||||||
|
|
||||||
|
expectStatus(resp, body).toBe(200);
|
||||||
|
expect(body.isAvailable).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { beforeAll, describe, expect, it } from "bun:test";
|
import { beforeAll, describe, expect, it } from "bun:test";
|
||||||
import { createSerie, getSerie } from "tests/helpers";
|
import { createSerie, createVideo, getSerie } from "tests/helpers";
|
||||||
import { expectStatus } from "tests/utils";
|
import { expectStatus } from "tests/utils";
|
||||||
import { madeInAbyss } from "~/models/examples";
|
import { madeInAbyss, madeInAbyssVideo } from "~/models/examples";
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
await createVideo(madeInAbyssVideo);
|
||||||
await createSerie(madeInAbyss);
|
await createSerie(madeInAbyss);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -20,7 +21,6 @@ describe("Get seasons", () => {
|
|||||||
it("With a valid entryCount/availableCount", async () => {
|
it("With a valid entryCount/availableCount", async () => {
|
||||||
const [resp, body] = await getSerie(madeInAbyss.slug, { langs: "en" });
|
const [resp, body] = await getSerie(madeInAbyss.slug, { langs: "en" });
|
||||||
|
|
||||||
console.log(body)
|
|
||||||
expectStatus(resp, body).toBe(200);
|
expectStatus(resp, body).toBe(200);
|
||||||
expect(body.entriesCount).toBe(madeInAbyss.entries.length);
|
expect(body.entriesCount).toBe(madeInAbyss.entries.length);
|
||||||
expect(body.availableCount).toBe(1);
|
expect(body.availableCount).toBe(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user