Update availableSince of entries on POST /videos

This commit is contained in:
2025-05-03 16:36:31 +02:00
parent 205dda652a
commit 46d98e038d
3 changed files with 43 additions and 27 deletions

View File

@@ -10,7 +10,7 @@ import { conflictUpdateAllExcept, sqlarr, values } from "~/db/utils";
import type { SeedEntry as SEntry, SeedExtra as SExtra } from "~/models/entry";
import { enqueueOptImage } from "../images";
import { guessNextRefresh } from "../refresh";
import { updateAvailableCount } from "./shows";
import { updateAvailableCount, updateAvailableSince } from "./shows";
type SeedEntry = SEntry & {
video?: undefined;
@@ -192,16 +192,7 @@ export const insertEntries = async (
if (!onlyExtras)
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),
),
);
await updateAvailableSince(tx,[...new Set(vids.map((x) => x.entryPk))]);
return ret;
});