1
0

fix: incorrect target for calculating eta

This commit is contained in:
alikia2x (寒寒) 2025-10-08 04:43:53 +08:00
parent 14be6d51b2
commit 39ae323269
3 changed files with 7 additions and 3 deletions

View File

@ -81,8 +81,11 @@ export const snapshotTickWorker = async (_job: Job) => {
}
};
export const closetMilestone = (views: number) => {
export const closetMilestone = (views: number, strict: boolean = false) => {
if (views < 100000) return 100000;
if (views < 1000000) return 1000000;
if (views < 10000000) {
return strict ? 10000000 : Math.ceil(views / 1000000) * 1000000;
}
return Math.ceil(views / 1000000) * 1000000;
};

View File

@ -51,7 +51,7 @@ export const takeBulkSnapshotForVideosWorker = async (job: Job) => {
const viewsDiff = views - currentSnapshot.views;
const hoursDiff = (new Date().getTime() - currentSnapshot.created_at) / HOUR;
const speed = viewsDiff / (hoursDiff + DELTA);
const target = closetMilestone(views);
const target = closetMilestone(views, true);
const viewsToIncrease = target - views;
const eta = viewsToIncrease / (speed + DELTA);
await updateETA(sql, aid, eta, speed, views);

View File

@ -65,7 +65,8 @@ export const getAdjustedShortTermETA = async (sql: Psql, aid: number) => {
minETAHours = Infinity;
}
const avgETAHours = viewsToIncrease / (avgSpeed + DELTA);
const remaining = closetMilestone(latestSnapshot.views, true) - latestSnapshot.views;
const avgETAHours = remaining / (avgSpeed + DELTA);
await updateETA(sql, aid, avgETAHours, avgSpeed, latestSnapshot.views);