mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Add availableSince
field on entries (will be used for /news)
This commit is contained in:
parent
878d72f3a4
commit
621d4752ba
@ -1,4 +1,4 @@
|
|||||||
import { type Column, type SQL, eq, sql } from "drizzle-orm";
|
import { type Column, type SQL, and, eq, isNull, sql } from "drizzle-orm";
|
||||||
import { db } from "~/db";
|
import { db } from "~/db";
|
||||||
import {
|
import {
|
||||||
entries,
|
entries,
|
||||||
@ -6,7 +6,7 @@ import {
|
|||||||
entryVideoJoin,
|
entryVideoJoin,
|
||||||
videos,
|
videos,
|
||||||
} from "~/db/schema";
|
} from "~/db/schema";
|
||||||
import { conflictUpdateAllExcept, values } from "~/db/utils";
|
import { conflictUpdateAllExcept, sqlarr, values } from "~/db/utils";
|
||||||
import type { SeedEntry as SEntry, SeedExtra as SExtra } from "~/models/entry";
|
import type { SeedEntry as SEntry, SeedExtra as SExtra } from "~/models/entry";
|
||||||
import { processOptImage } from "../images";
|
import { processOptImage } from "../images";
|
||||||
import { guessNextRefresh } from "../refresh";
|
import { guessNextRefresh } from "../refresh";
|
||||||
@ -168,6 +168,17 @@ export const insertEntries = async (
|
|||||||
|
|
||||||
if (!onlyExtras)
|
if (!onlyExtras)
|
||||||
await updateAvailableCount(tx, [show.pk], show.kind === "serie");
|
await updateAvailableCount(tx, [show.pk], show.kind === "serie");
|
||||||
|
|
||||||
|
const entriesPk = [...new Set(vids.map((x) => x.entryPk))];
|
||||||
|
await tx
|
||||||
|
.update(entries)
|
||||||
|
.set({ availableSince: sql`now()` })
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(entries.pk, sql`any(${sqlarr(entriesPk)})`),
|
||||||
|
isNull(entries.availableSince),
|
||||||
|
),
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ export const entries = schema.table(
|
|||||||
updatedAt: timestamp({ withTimezone: true, mode: "string" })
|
updatedAt: timestamp({ withTimezone: true, mode: "string" })
|
||||||
.notNull()
|
.notNull()
|
||||||
.$onUpdate(() => sql`now()`),
|
.$onUpdate(() => sql`now()`),
|
||||||
|
availableSince: timestamp({ withTimezone: true, mode: "string" }),
|
||||||
nextRefresh: timestamp({ withTimezone: true, mode: "string" }).notNull(),
|
nextRefresh: timestamp({ withTimezone: true, mode: "string" }).notNull(),
|
||||||
},
|
},
|
||||||
(t) => [
|
(t) => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user