fix: ignored the case of inserting schedule when type = 'milestone' in scheduleSnapshot
This commit is contained in:
parent
288e4f9571
commit
6eaaf921d6
@ -182,11 +182,15 @@ export async function scheduleSnapshot(
|
|||||||
force: boolean = false,
|
force: boolean = false,
|
||||||
) {
|
) {
|
||||||
let adjustedTime = new Date(targetTime);
|
let adjustedTime = new Date(targetTime);
|
||||||
if (type == "milestone") {
|
const hashActiveSchedule = await videoHasActiveScheduleWithType(client, aid, type);
|
||||||
await client.queryObject(
|
if (type == "milestone" && hashActiveSchedule) {
|
||||||
`UPDATE snapshot_schedule SET started_at = $1 WHERE aid = $2 AND type = 'milestone' AND status = 'pending'`,
|
await client.queryObject(`
|
||||||
[adjustedTime, aid],
|
UPDATE snapshot_schedule
|
||||||
);
|
SET started_at = $1
|
||||||
|
WHERE aid = $2
|
||||||
|
AND type = 'milestone'
|
||||||
|
AND (status = 'pending' OR status = 'processing')
|
||||||
|
`, [adjustedTime, aid]);
|
||||||
logger.log(
|
logger.log(
|
||||||
`Updated snapshot schedule for ${aid} at ${adjustedTime.toISOString()}`,
|
`Updated snapshot schedule for ${aid} at ${adjustedTime.toISOString()}`,
|
||||||
"mq",
|
"mq",
|
||||||
@ -194,7 +198,7 @@ export async function scheduleSnapshot(
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (await videoHasActiveScheduleWithType(client, aid, type) && !force) return;
|
if (hashActiveSchedule && !force) return;
|
||||||
if (type !== "milestone" && type !== "new") {
|
if (type !== "milestone" && type !== "new") {
|
||||||
adjustedTime = await adjustSnapshotTime(new Date(targetTime), 2000, redis);
|
adjustedTime = await adjustSnapshotTime(new Date(targetTime), 2000, redis);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user