From cabb360a16c7da3428e275774be6cc3b03ed6ade Mon Sep 17 00:00:00 2001 From: alikia2x Date: Tue, 25 Mar 2025 22:58:56 +0800 Subject: [PATCH] fix: missing entrance for schedule type 'new' update: perf log text --- lib/db/snapshotSchedule.ts | 6 +++--- lib/mq/exec/classifyVideo.ts | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/db/snapshotSchedule.ts b/lib/db/snapshotSchedule.ts index 26f1df2..e38fa83 100644 --- a/lib/db/snapshotSchedule.ts +++ b/lib/db/snapshotSchedule.ts @@ -201,18 +201,18 @@ export async function adjustSnapshotTime( if (delayedDate.getTime() < now.getTime()) { const elapsed = performance.now() - t; timePerIteration = elapsed / i; - logger.log(`Time per iteration: ${timePerIteration.toFixed(3)}ms`, "perf", "fn:adjustSnapshotTime"); + logger.log(`${timePerIteration.toFixed(3)}ms * ${i}iterations`, "perf", "fn:adjustSnapshotTime"); return now; } const elapsed = performance.now() - t; timePerIteration = elapsed / i; - logger.log(`Time per iteration: ${timePerIteration.toFixed(3)}ms`, "perf", "fn:adjustSnapshotTime"); + logger.log(`${timePerIteration.toFixed(3)}ms * ${i}iterations`, "perf", "fn:adjustSnapshotTime"); return delayedDate; } } const elapsed = performance.now() - t; timePerIteration = elapsed / WINDOW_SIZE; - logger.log(`Time per iteration: ${timePerIteration.toFixed(3)}ms`, "perf", "fn:adjustSnapshotTime"); + logger.log(`${timePerIteration.toFixed(3)}ms * ${WINDOW_SIZE}iterations`, "perf", "fn:adjustSnapshotTime"); return expectedStartTime; } diff --git a/lib/mq/exec/classifyVideo.ts b/lib/mq/exec/classifyVideo.ts index b86a9a6..20545a0 100644 --- a/lib/mq/exec/classifyVideo.ts +++ b/lib/mq/exec/classifyVideo.ts @@ -7,6 +7,8 @@ import logger from "lib/log/logger.ts"; import { lockManager } from "lib/mq/lockManager.ts"; import { aidExistsInSongs } from "lib/db/songs.ts"; import { insertIntoSongs } from "lib/mq/task/collectSongs.ts"; +import { scheduleSnapshot } from "lib/db/snapshotSchedule.ts"; +import { MINUTE } from "$std/datetime/constants.ts"; export const classifyVideoWorker = async (job: Job) => { const client = await db.connect(); @@ -27,6 +29,7 @@ export const classifyVideoWorker = async (job: Job) => { const exists = await aidExistsInSongs(client, aid); if (!exists && label !== 0) { + await scheduleSnapshot(client, aid, "new", Date.now() + 10 * MINUTE, true); await insertIntoSongs(client, aid); }