fix: ignored the case where snapshots are actually the same

This commit is contained in:
alikia2x (寒寒) 2025-03-24 03:49:06 +08:00
parent 6f4a26e8b3
commit 8be68248df
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6

View File

@ -136,6 +136,7 @@ const getRegularSnapshotInterval = async (client: Client, aid: number) => {
const oldSnapshot = await findClosestSnapshot(client, aid, date); const oldSnapshot = await findClosestSnapshot(client, aid, date);
const latestSnapshot = await getLatestSnapshot(client, aid); const latestSnapshot = await getLatestSnapshot(client, aid);
if (!oldSnapshot || !latestSnapshot) return 0; if (!oldSnapshot || !latestSnapshot) return 0;
if (oldSnapshot.created_at === latestSnapshot.created_at) return 0;
const hoursDiff = (latestSnapshot.created_at - oldSnapshot.created_at) / HOUR; const hoursDiff = (latestSnapshot.created_at - oldSnapshot.created_at) / HOUR;
if (hoursDiff < 8) return 24; if (hoursDiff < 8) return 24;
const viewsDiff = latestSnapshot.views - oldSnapshot.views; const viewsDiff = latestSnapshot.views - oldSnapshot.views;