mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix entries's video retrieval
This commit is contained in:
parent
d61573668b
commit
34926dab51
@ -41,6 +41,7 @@ import {
|
|||||||
sortToSql,
|
sortToSql,
|
||||||
} from "~/models/utils";
|
} from "~/models/utils";
|
||||||
import { desc } from "~/models/utils/descriptions";
|
import { desc } from "~/models/utils/descriptions";
|
||||||
|
import type { EmbeddedVideo } from "~/models/video";
|
||||||
|
|
||||||
const entryFilters: FilterDef = {
|
const entryFilters: FilterDef = {
|
||||||
kind: {
|
kind: {
|
||||||
@ -115,9 +116,14 @@ async function getEntries({
|
|||||||
const videosQ = db
|
const videosQ = db
|
||||||
.select({
|
.select({
|
||||||
videos: coalesce(
|
videos: coalesce(
|
||||||
jsonbAgg(jsonbBuildObject({ slug: entryVideoJoin.slug, ...videosCol })),
|
jsonbAgg(
|
||||||
|
jsonbBuildObject<EmbeddedVideo>({
|
||||||
|
slug: entryVideoJoin.slug,
|
||||||
|
...videosCol,
|
||||||
|
}),
|
||||||
|
),
|
||||||
sql`'[]'::jsonb`,
|
sql`'[]'::jsonb`,
|
||||||
),
|
).as("videos"),
|
||||||
})
|
})
|
||||||
.from(entryVideoJoin)
|
.from(entryVideoJoin)
|
||||||
.where(eq(entryVideoJoin.entryPk, entries.pk))
|
.where(eq(entryVideoJoin.entryPk, entries.pk))
|
||||||
|
@ -73,7 +73,7 @@ export const Video = t.Intersect([Resource(), SeedVideo, DbMetadata]);
|
|||||||
export type Video = Prettify<typeof Video.static>;
|
export type Video = Prettify<typeof Video.static>;
|
||||||
|
|
||||||
// type used in entry responses
|
// type used in entry responses
|
||||||
export const EmbeddedVideo = t.Omit(Video, ["createdAt", "updatedAt"]);
|
export const EmbeddedVideo = t.Omit(Video, ["guess", "createdAt", "updatedAt"]);
|
||||||
export type EmbeddedVideo = Prettify<typeof EmbeddedVideo.static>;
|
export type EmbeddedVideo = Prettify<typeof EmbeddedVideo.static>;
|
||||||
|
|
||||||
registerExamples(Video, bubbleVideo);
|
registerExamples(Video, bubbleVideo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user