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:
1 parent
d0f30c11b7
commit
157b9fe20c
4 files changed
+64
-6
No files matched your search
@@ -86,7 +86,12 @@ export function sourceHealth(
|
||||
// When the bytes were last confirmed live; a fixture's capture date when
|
||||
// this source has never been refreshed.
|
||||
lastSuccessAt: at,
|
||||
lastConfirmedAt: timestamps?.lastConfirmedAt ?? null,
|
||||
lastConfirmedAt:
|
||||
timestamps?.lastConfirmedAt != null &&
|
||||
(timestamps.contentChangedAt ?? at) != null &&
|
||||
Date.parse(timestamps.lastConfirmedAt) < Date.parse(timestamps.contentChangedAt ?? at!)
|
||||
? (timestamps.contentChangedAt ?? at)
|
||||
: (timestamps?.lastConfirmedAt ?? null),
|
||||
contentChangedAt: timestamps?.contentChangedAt ?? at,
|
||||
eventCount,
|
||||
parsedCount,
|
||||
|
||||
+13
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user