From d6dd4d933437087d30ae0830aaacc3fda3f7a57a Mon Sep 17 00:00:00 2001 From: alikia2x Date: Thu, 27 Mar 2025 02:09:48 +0800 Subject: [PATCH] fix: potential shifting for obtained window offset in last commit --- lib/db/snapshotSchedule.ts | 2 +- lib/mq/exec/snapshotTick.ts | 1 + lib/net/bilibili.d.ts | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/db/snapshotSchedule.ts b/lib/db/snapshotSchedule.ts index 1aa2d06..04bbe6e 100644 --- a/lib/db/snapshotSchedule.ts +++ b/lib/db/snapshotSchedule.ts @@ -207,7 +207,7 @@ export async function adjustSnapshotTime( let initialOffset = 0; if (lastAvailableWindow && lastAvailableWindow.count < allowedCounts) { - initialOffset = lastAvailableWindow.offset; + initialOffset = Math.max(lastAvailableWindow.offset - 2, 0); } let timePerIteration = 0; diff --git a/lib/mq/exec/snapshotTick.ts b/lib/mq/exec/snapshotTick.ts index 2a25265..e2c4ccf 100644 --- a/lib/mq/exec/snapshotTick.ts +++ b/lib/mq/exec/snapshotTick.ts @@ -160,6 +160,7 @@ export const regularSnapshotsWorker = async (_job: Job) => { const startedAt = Date.now(); if (await lockManager.isLocked("dispatchRegularSnapshots")) { logger.log("dispatchRegularSnapshots is already running", "mq"); + client.release(); return; } await lockManager.acquireLock("dispatchRegularSnapshots", 30 * 60); diff --git a/lib/net/bilibili.d.ts b/lib/net/bilibili.d.ts index 6a66ecc..964a87e 100644 --- a/lib/net/bilibili.d.ts +++ b/lib/net/bilibili.d.ts @@ -9,6 +9,24 @@ export type VideoListResponse = BaseResponse; export type VideoDetailsResponse = BaseResponse; export type VideoTagsResponse = BaseResponse; export type VideoInfoResponse = BaseResponse; +export type MediaListInfoResponse = BaseResponse; + +type MediaListInfoData = MediaListInfoItem[]; + + +interface MediaListInfoItem { + bvid: string; + id: number; + cnt_info: { + coin: number; + collect: number; + danmaku: number; + play: number; + reply: number; + share: number; + thumb_up: number; + } +} interface VideoInfoData { bvid: string;