fix: ignored the case of inserting schedule when type = 'milestone' in scheduleSnapshot

This commit is contained in:
alikia2x (寒寒) 2025-04-15 22:06:14 +08:00
parent 288e4f9571
commit 6eaaf921d6
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6

View File

@ -182,11 +182,15 @@ export async function scheduleSnapshot(
force: boolean = false,
) {
let adjustedTime = new Date(targetTime);
if (type == "milestone") {
await client.queryObject(
`UPDATE snapshot_schedule SET started_at = $1 WHERE aid = $2 AND type = 'milestone' AND status = 'pending'`,
[adjustedTime, aid],
);
const hashActiveSchedule = await videoHasActiveScheduleWithType(client, aid, type);
if (type == "milestone" && hashActiveSchedule) {
await client.queryObject(`
UPDATE snapshot_schedule
SET started_at = $1
WHERE aid = $2
AND type = 'milestone'
AND (status = 'pending' OR status = 'processing')
`, [adjustedTime, aid]);
logger.log(
`Updated snapshot schedule for ${aid} at ${adjustedTime.toISOString()}`,
"mq",
@ -194,7 +198,7 @@ export async function scheduleSnapshot(
);
return;
}
if (await videoHasActiveScheduleWithType(client, aid, type) && !force) return;
if (hashActiveSchedule && !force) return;
if (type !== "milestone" && type !== "new") {
adjustedTime = await adjustSnapshotTime(new Date(targetTime), 2000, redis);
}