fix: milestone snapshot being ignore when a pending schedule exists

This commit is contained in:
alikia2x (寒寒) 2025-04-05 06:22:25 +08:00
parent 22b1c337ac
commit 13ed20cf5c
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
4 changed files with 15 additions and 7 deletions

View File

@ -3,13 +3,9 @@ import { LatestSnapshotType } from "db/schema.d.ts";
export async function getVideosNearMilestone(client: Client) {
const queryResult = await client.queryObject<LatestSnapshotType>(`
SELECT ls.*
SELECT ls
FROM latest_video_snapshot ls
INNER JOIN
songs s ON ls.aid = s.aid
AND s.deleted = false
WHERE
s.deleted = false AND
(views >= 90000 AND views < 100000) OR
(views >= 900000 AND views < 1000000) OR
(views >= 9900000 AND views < 10000000)

View File

@ -4,4 +4,4 @@
// SO HERE'S A PLACHOLDER EXPORT FOR DENO:
export const DENO = "FUCK YOU DENO";
// Oh, maybe export the version is a good idea
export const VERSION = "1.0.17";
export const VERSION = "1.0.18";

View File

@ -161,7 +161,7 @@ export const collectMilestoneSnapshotsWorker = async (_job: Job) => {
const minInterval = 1 * SECOND;
const delay = truncate(scheduledNextSnapshotDelay, minInterval, maxInterval);
const targetTime = now + delay;
await scheduleSnapshot(client, aid, "milestone", targetTime);
await scheduleSnapshot(client, aid, "milestone", targetTime, true);
}
} catch (e) {
logger.error(e as Error, "mq", "fn:collectMilestoneSnapshotsWorker");

View File

@ -42,6 +42,18 @@ export async function insertVideoInfo(client: Client, aid: number) {
[data.Card.follower, uid],
);
}
const stat = data.View.stat;
const query: string = `
INSERT INTO video_snapshot (aid, views, danmakus, replies, likes, coins, shares, favorites)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
`;
await client.queryObject(
query,
[aid, stat.view, stat.danmaku, stat.reply, stat.like, stat.coin, stat.share, stat.favorite],
);
logger.log(`Inserted video metadata for aid: ${aid}`, "mq");
await ClassifyVideoQueue.add("classifyVideo", { aid });
}