This commit is contained in:
Marcelo
2026-04-24 20:47:25 +00:00
parent 30513ff73d
commit 66c89f9bf4
5 changed files with 83 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ const STOP_TYPES = new Set(["microstop", "macrostop"]);
const STOP_STATUS = new Set(["STOP", "DOWN", "OFFLINE"]);
const CACHE_TTL_SEC = 60;
const MOLD_LOOKBACK_MS = 14 * 24 * 60 * 60 * 1000;
const MOLD_ACTIVE_STALE_MS = 12 * 60 * 60 * 1000;
function safeNum(value: unknown) {
if (typeof value === "number" && Number.isFinite(value)) return value;
@@ -822,6 +823,7 @@ async function computeRecap(params: Required<Pick<RecapQuery, "orgId">> & {
continue;
}
if (status === "active" || !status) {
if (params.end.getTime() - event.ts.getTime() > MOLD_ACTIVE_STALE_MS) continue;
moldActiveByIncident.set(key, moldStartMs(event.data, event.ts));
}
}