fix(feed): reflect content updates in source health confirmation and freshness

Ensure lastConfirmedAt never precedes contentChangedAt for fetched snapshots and calculate game-level lastConfirmedAt using effective pull times.
This commit is contained in:
Lucas Winther
2026-09-18 09:30:31 +02:00
parent d0f30c11b7
commit 157b9fe20c
4 changed files with 64 additions and 6 deletions
+13 -3
View File
@@ -167,11 +167,21 @@ export function freshness(
let lastConfirmedAt: string | null = null;
let hasConfirmed = false;
for (const s of sourcesInfo) {
const pullAt =
s.lastConfirmedAt !== null &&
s.contentChangedAt !== null &&
Date.parse(s.lastConfirmedAt) >= Date.parse(s.contentChangedAt)
? s.lastConfirmedAt
: (s.lastConfirmedAt ??
(s.contentChangedAt && now - Date.parse(s.contentChangedAt) <= STALE_AFTER_MS
? s.contentChangedAt
: null));
if (!hasConfirmed) {
lastConfirmedAt = s.lastConfirmedAt;
lastConfirmedAt = pullAt;
hasConfirmed = true;
} else if (lastConfirmedAt !== null && (s.lastConfirmedAt === null || s.lastConfirmedAt < lastConfirmedAt)) {
lastConfirmedAt = s.lastConfirmedAt;
} else if (lastConfirmedAt !== null && (pullAt === null || pullAt < lastConfirmedAt)) {
lastConfirmedAt = pullAt;
}
}