mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Create migration & fix update statment
This commit is contained in:
parent
c58cb3ef78
commit
54ee704ab9
2
api/drizzle/0012_available_count.sql
Normal file
2
api/drizzle/0012_available_count.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "kyoo"."shows" ADD COLUMN "entries_count" integer NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "kyoo"."shows" ADD COLUMN "available_count" integer DEFAULT 0 NOT NULL;
|
1278
api/drizzle/meta/0012_snapshot.json
Normal file
1278
api/drizzle/meta/0012_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -85,6 +85,13 @@
|
|||||||
"when": 1741014917375,
|
"when": 1741014917375,
|
||||||
"tag": "0011_join_rename",
|
"tag": "0011_join_rename",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 12,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1741360992371,
|
||||||
|
"tag": "0012_available_count",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ export const insertCollection = async (
|
|||||||
startAir: show.kind === "movie" ? show.airDate : show.startAir,
|
startAir: show.kind === "movie" ? show.airDate : show.startAir,
|
||||||
endAir: show.kind === "movie" ? show.airDate : show.endAir,
|
endAir: show.kind === "movie" ? show.airDate : show.endAir,
|
||||||
nextRefresh: show.nextRefresh,
|
nextRefresh: show.nextRefresh,
|
||||||
|
entriesCount: 0,
|
||||||
...col,
|
...col,
|
||||||
})
|
})
|
||||||
.onConflictDoUpdate({
|
.onConflictDoUpdate({
|
||||||
|
@ -101,8 +101,8 @@ export async function updateAvailableCount(
|
|||||||
return await db
|
return await db
|
||||||
.update(shows)
|
.update(shows)
|
||||||
.set({
|
.set({
|
||||||
availableCount: db
|
availableCount: sql`${db
|
||||||
.select({ availableCount: count() })
|
.select({ count: count() })
|
||||||
.from(entries)
|
.from(entries)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
@ -114,12 +114,12 @@ export async function updateAvailableCount(
|
|||||||
.where(eq(entryVideoJoin.entryPk, entries.pk)),
|
.where(eq(entryVideoJoin.entryPk, entries.pk)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)}`,
|
||||||
...(updateEntryCount && {
|
...(updateEntryCount && {
|
||||||
entriesCount: db
|
entriesCount: sql`${db
|
||||||
.select({ entriesCount: count() })
|
.select({ count: count() })
|
||||||
.from(entries)
|
.from(entries)
|
||||||
.where(eq(entries.showPk, shows.pk)),
|
.where(eq(entries.showPk, shows.pk))}`,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.where(eq(shows.pk, sql`any(${sqlarr(showPks)})`));
|
.where(eq(shows.pk, sql`any(${sqlarr(showPks)})`));
|
||||||
|
@ -12,7 +12,7 @@ export const madeInAbyssVideo: Video = {
|
|||||||
title: "Made in abyss",
|
title: "Made in abyss",
|
||||||
season: [1],
|
season: [1],
|
||||||
episode: [13],
|
episode: [13],
|
||||||
type: "episode",
|
kind: "episode",
|
||||||
from: "guessit",
|
from: "guessit",
|
||||||
},
|
},
|
||||||
createdAt: "2024-11-23T15:01:24.968Z",
|
createdAt: "2024-11-23T15:01:24.968Z",
|
||||||
|
@ -88,7 +88,7 @@ export const FullSerie = t.Intersect([
|
|||||||
export type FullMovie = Prettify<typeof FullSerie.static>;
|
export type FullMovie = Prettify<typeof FullSerie.static>;
|
||||||
|
|
||||||
export const SeedSerie = t.Intersect([
|
export const SeedSerie = t.Intersect([
|
||||||
t.Omit(BaseSerie, ["kind", "nextRefresh", "entriesCount"]),
|
t.Omit(BaseSerie, ["kind", "nextRefresh", "entriesCount", "availableCount"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
slug: t.String({ format: "slug" }),
|
||||||
translations: TranslationRecord(
|
translations: TranslationRecord(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user