update: force schedule for new songs

This commit is contained in:
alikia2x (寒寒) 2025-03-25 04:52:19 +08:00
parent 6b7142a6d5
commit a178b7fc16
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
3 changed files with 4 additions and 4 deletions

View File

@ -159,8 +159,8 @@ export async function getSnapshotScheduleCountWithinRange(client: Client, start:
* @param aid The aid of the video. * @param aid The aid of the video.
* @param targetTime Scheduled time for snapshot. (Timestamp in milliseconds) * @param targetTime Scheduled time for snapshot. (Timestamp in milliseconds)
*/ */
export async function scheduleSnapshot(client: Client, aid: number, type: string, targetTime: number) { export async function scheduleSnapshot(client: Client, aid: number, type: string, targetTime: number, force: boolean = false) {
if (await videoHasActiveSchedule(client, aid)) return; if (await videoHasActiveSchedule(client, aid) && !force) return;
let adjustedTime = new Date(targetTime); let adjustedTime = new Date(targetTime);
if (type !== "milestone" && type !== "new") { if (type !== "milestone" && type !== "new") {
adjustedTime = await adjustSnapshotTime(new Date(targetTime), 1000, redis); adjustedTime = await adjustSnapshotTime(new Date(targetTime), 1000, redis);

View File

@ -227,7 +227,7 @@ export const takeSnapshotForVideoWorker = async (job: Job) => {
if (viewsPerHour > 1000) { if (viewsPerHour > 1000) {
intervalMins = 15; intervalMins = 15;
} }
await scheduleSnapshot(client, aid, type, Date.now() + intervalMins * MINUTE); await scheduleSnapshot(client, aid, type, Date.now() + intervalMins * MINUTE, true);
} }
if (type !== "milestone") return `DONE`; if (type !== "milestone") return `DONE`;
const eta = await getAdjustedShortTermETA(client, aid); const eta = await getAdjustedShortTermETA(client, aid);

View File

@ -10,7 +10,7 @@ export async function collectSongs(client: Client) {
const exists = await aidExistsInSongs(client, aid); const exists = await aidExistsInSongs(client, aid);
if (exists) continue; if (exists) continue;
await insertIntoSongs(client, aid); await insertIntoSongs(client, aid);
await scheduleSnapshot(client, aid, "new", Date.now() + 10 * MINUTE); await scheduleSnapshot(client, aid, "new", Date.now() + 10 * MINUTE, true);
logger.log(`Video ${aid} was added into the songs table.`, "mq", "fn:collectSongs"); logger.log(`Video ${aid} was added into the songs table.`, "mq", "fn:collectSongs");
} }
} }