mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
improve watch history reliability
- Reduced view threshold from 12s to 5s in watchHistoryTelemetry.js - Enabled immediate watch history republishing (0ms delay) for the first attempt in watchHistory.js - Updated watchHistoryService.js to recursively schedule queue flushes if items accumulate during an inflight sync
This commit is contained in:
1 parent
6b1ce04af6
commit
a484fb8f36
3 files changed
+24
-9
No files matched your search
@@ -1101,13 +1101,25 @@ class WatchHistoryManager {
|
||||
if (attempt > WATCH_HISTORY_REPUBLISH_MAX_ATTEMPTS) {
|
||||
return;
|
||||
}
|
||||
const exponentialDelay = WATCH_HISTORY_REPUBLISH_BASE_DELAY_MS * Math.pow(2, attempt);
|
||||
const cappedDelay = Math.min(exponentialDelay, WATCH_HISTORY_REPUBLISH_MAX_DELAY_MS);
|
||||
const jitter = Math.random() * cappedDelay * WATCH_HISTORY_REPUBLISH_JITTER;
|
||||
const delay = Math.max(
|
||||
WATCH_HISTORY_REPUBLISH_BASE_DELAY_MS,
|
||||
Math.floor(cappedDelay + jitter),
|
||||
);
|
||||
|
||||
let delay = 0;
|
||||
if (attempt === 0) {
|
||||
delay = 10;
|
||||
} else {
|
||||
const exponentialDelay =
|
||||
WATCH_HISTORY_REPUBLISH_BASE_DELAY_MS * Math.pow(2, attempt);
|
||||
const cappedDelay = Math.min(
|
||||
exponentialDelay,
|
||||
WATCH_HISTORY_REPUBLISH_MAX_DELAY_MS,
|
||||
);
|
||||
const jitter =
|
||||
Math.random() * cappedDelay * WATCH_HISTORY_REPUBLISH_JITTER;
|
||||
delay = Math.max(
|
||||
WATCH_HISTORY_REPUBLISH_BASE_DELAY_MS,
|
||||
Math.floor(cappedDelay + jitter),
|
||||
);
|
||||
}
|
||||
|
||||
if (onSchedule) {
|
||||
try {
|
||||
onSchedule({ taskId: key, attempt: attempt + 1, delay });
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
ingestLocalViewEvent as defaultIngestLocalViewEvent,
|
||||
} from "../viewCounter.js";
|
||||
|
||||
const DEFAULT_VIEW_THRESHOLD_SECONDS = 12;
|
||||
const DEFAULT_VIEW_THRESHOLD_SECONDS = 5;
|
||||
|
||||
function normalizeString(value) {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
|
||||
@@ -615,12 +615,15 @@ function scheduleRepublishForQueue(actorKey) {
|
||||
actorKey,
|
||||
queue,
|
||||
keysToClear,
|
||||
snapshotStartTime
|
||||
snapshotStartTime,
|
||||
);
|
||||
await updateFingerprintCache(
|
||||
actorKey,
|
||||
publishResult.items || latestItems,
|
||||
);
|
||||
if (queue.items.size > 0) {
|
||||
scheduleRepublishForQueue(actorKey);
|
||||
}
|
||||
} else if (!publishResult?.retryable) {
|
||||
// If not retryable, we clear the scheduled flag to allow new attempts later
|
||||
queue.republishScheduled = false;
|
||||
|
||||
Reference in new issue
Block a user