mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-22 07:02:27 -04:00
Add support for externalId in POST /videos
This commit is contained in:
@@ -213,7 +213,7 @@ export async function getEntries({
|
||||
})
|
||||
.from(entries)
|
||||
.innerJoin(transQ, eq(entries.pk, transQ.pk))
|
||||
.leftJoinLateral(entryVideosQ, sql`true`)
|
||||
.crossJoinLateral(entryVideosQ)
|
||||
.leftJoin(progressQ, eq(entries.pk, progressQ.entryPk))
|
||||
.where(
|
||||
and(
|
||||
|
||||
@@ -286,7 +286,7 @@ export const historyH = new Elysia({ tags: ["profiles"] })
|
||||
})
|
||||
.from(hist)
|
||||
.leftJoin(entries, valEqEntries)
|
||||
.leftJoinLateral(nextEntryQ, sql`true`),
|
||||
.crossJoinLateral(nextEntryQ),
|
||||
)
|
||||
.onConflictDoUpdate({
|
||||
target: [watchlist.profilePk, watchlist.showPk],
|
||||
|
||||
@@ -112,7 +112,7 @@ export const nextup = new Elysia({ tags: ["profiles"] })
|
||||
.from(entries)
|
||||
.innerJoin(watchlist, eq(watchlist.nextEntry, entries.pk))
|
||||
.innerJoin(transQ, eq(entries.pk, transQ.pk))
|
||||
.leftJoinLateral(entryVideosQ, sql`true`)
|
||||
.crossJoinLateral(entryVideosQ)
|
||||
.leftJoin(entryProgressQ, eq(entries.pk, entryProgressQ.entryPk))
|
||||
.where(
|
||||
and(
|
||||
|
||||
@@ -41,7 +41,7 @@ import { entryProgressQ, entryVideosQ, mapProgress } from "../entries";
|
||||
export const watchStatusQ = db
|
||||
.select({
|
||||
...getColumns(watchlist),
|
||||
percent: sql`${watchlist.seenCount}`.as("percent"),
|
||||
percent: sql<number>`${watchlist.seenCount}`.as("percent"),
|
||||
})
|
||||
.from(watchlist)
|
||||
.leftJoin(profiles, eq(watchlist.profilePk, profiles.pk))
|
||||
@@ -161,9 +161,9 @@ const showRelations = {
|
||||
).as("videos"),
|
||||
})
|
||||
.from(entryVideoJoin)
|
||||
.innerJoin(entries, eq(entries.showPk, shows.pk))
|
||||
.innerJoin(videos, eq(videos.pk, entryVideoJoin.videoPk))
|
||||
.where(eq(entryVideoJoin.entryPk, entries.pk))
|
||||
.leftJoin(entries, eq(entries.showPk, shows.pk))
|
||||
.leftJoin(videos, eq(videos.pk, entryVideoJoin.videoPk))
|
||||
.as("videos");
|
||||
},
|
||||
firstEntry: ({ languages }: { languages: string[] }) => {
|
||||
@@ -190,7 +190,7 @@ const showRelations = {
|
||||
.from(entries)
|
||||
.innerJoin(transQ, eq(entries.pk, transQ.pk))
|
||||
.leftJoin(entryProgressQ, eq(entries.pk, entryProgressQ.entryPk))
|
||||
.leftJoinLateral(entryVideosQ, sql`true`)
|
||||
.crossJoinLateral(entryVideosQ)
|
||||
.where(and(eq(entries.showPk, shows.pk), ne(entries.kind, "extra")))
|
||||
.orderBy(entries.order)
|
||||
.limit(1)
|
||||
@@ -220,7 +220,7 @@ const showRelations = {
|
||||
.from(entries)
|
||||
.innerJoin(transQ, eq(entries.pk, transQ.pk))
|
||||
.leftJoin(entryProgressQ, eq(entries.pk, entryProgressQ.entryPk))
|
||||
.leftJoinLateral(entryVideosQ, sql`true`)
|
||||
.crossJoinLateral(entryVideosQ)
|
||||
.where(eq(watchStatusQ.nextEntry, entries.pk))
|
||||
.as("nextEntry");
|
||||
},
|
||||
|
||||
@@ -53,9 +53,8 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
slug: shows.slug,
|
||||
})
|
||||
.from(videos)
|
||||
.leftJoin(
|
||||
.crossJoin(
|
||||
sql`jsonb_array_elements_text(${videos.guess}->'year') as year`,
|
||||
sql`true`,
|
||||
)
|
||||
.innerJoin(entryVideoJoin, eq(entryVideoJoin.videoPk, videos.pk))
|
||||
.innerJoin(entries, eq(entries.pk, entryVideoJoin.entryPk))
|
||||
@@ -179,7 +178,6 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
return x.for.map((e) => ({
|
||||
video: vids.find((v) => v.path === x.path)!.pk,
|
||||
path: x.path,
|
||||
needRendering: x.for!.length > 1,
|
||||
entry: {
|
||||
...e,
|
||||
movie:
|
||||
@@ -216,6 +214,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
order: entries.order,
|
||||
showId: sql`${shows.id}`.as("showId"),
|
||||
showSlug: sql`${shows.slug}`.as("showSlug"),
|
||||
externalId: entries.externalId,
|
||||
})
|
||||
.from(entries)
|
||||
.innerJoin(shows, eq(entries.showPk, shows.pk))
|
||||
@@ -235,13 +234,12 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
videoPk: videos.pk,
|
||||
slug: computeVideoSlug(
|
||||
entriesQ.slug,
|
||||
sql`j.needRendering or exists(${hasRenderingQ})`,
|
||||
sql`exists(${hasRenderingQ})`,
|
||||
),
|
||||
})
|
||||
.from(
|
||||
values(vidEntries, {
|
||||
video: "integer",
|
||||
needRendering: "boolean",
|
||||
entry: "jsonb",
|
||||
}).as("j"),
|
||||
)
|
||||
@@ -293,6 +291,10 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
),
|
||||
),
|
||||
),
|
||||
and(
|
||||
sql`j.entry ? 'externalId'`,
|
||||
sql`j.entry->'externalId' <@ ${entriesQ.externalId}`,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user