Skip to content

Commit 33156d8

Browse files
authored
fix: use system time for nfds dispatch filtering (#1)
1 parent aaf1f65 commit 33156d8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/modules/ingest/app/sources/nfds-fire-dispatch.source.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,18 @@ export class NfdsFireDispatchSource implements Source {
7474
throw new Error('Failed to parse NFDS fire dispatch response');
7575
}
7676

77-
const rawNowDate = parsed.data.nowDate ?? null;
78-
const nowDate = parseNowDate(rawNowDate);
79-
const nowMs = nowDate ? nowDate.getTime() : Date.now();
80-
const nowIso = (nowDate ?? new Date()).toISOString();
77+
const rawNfdsDate = parsed.data.nowDate ?? null;
78+
const nfdsDate = parseNowDate(rawNfdsDate);
79+
const now = new Date();
80+
const nowMs = now.getTime();
81+
const nowIso = now.toISOString();
8182

8283
const previousState = parseState(state);
8384
const seen = new Map<string, string>(Object.entries(previousState.seen));
8485
const events: SourceEvent[] = [];
8586

8687
for (const item of parsed.data.defail) {
87-
const occurredAt = parseOccurredAt(item.overDate, nowDate);
88+
const occurredAt = parseOccurredAt(item.overDate, nfdsDate);
8889
if (isTooOld(occurredAt, nowMs, EVENT_MAX_AGE_MS)) {
8990
continue;
9091
}
@@ -95,7 +96,7 @@ export class NfdsFireDispatchSource implements Source {
9596
const isFirstIncident = !hasSeenIncident(seen, item.sidoOvrNum);
9697
const isProgressNotable = isNotableProgress(item.progressStat);
9798
if (isFirstIncident && isProgressNotable) {
98-
events.push(buildEvent(item, occurredAt, rawNowDate));
99+
events.push(buildEvent(item, occurredAt, rawNfdsDate));
99100
}
100101
}
101102
seen.set(key, nowIso);

0 commit comments

Comments
 (0)