Fix BU reassignment detail — fetch by count instead of time window
The BU history records may have been written days before the anomaly detected them leaving scope. Instead of a fragile time window, fetch the N most recent BU change records where N matches the classification count shown in the banner. This ensures the detail always matches the summary.
This commit is contained in:
@@ -247,18 +247,11 @@ export default function AnomalyBanner() {
|
||||
setBuLoading(true);
|
||||
setBuExpanded(true);
|
||||
try {
|
||||
// Fetch BU change records relevant to this anomaly.
|
||||
// Use a 25-hour window before sync_timestamp to capture changes from
|
||||
// the previous sync cycle (syncs run once per 24h).
|
||||
const since = anomaly?.sync_timestamp || '';
|
||||
let url;
|
||||
if (since) {
|
||||
const sinceDate = new Date(since);
|
||||
sinceDate.setHours(sinceDate.getHours() - 25);
|
||||
url = `${API_BASE}/ivanti/findings/bu-changes?since=${encodeURIComponent(sinceDate.toISOString())}`;
|
||||
} else {
|
||||
url = `${API_BASE}/ivanti/findings/bu-changes?limit=50`;
|
||||
}
|
||||
// Fetch the most recent BU change records, limited to the count shown
|
||||
// in the classification. This ensures the detail always matches the
|
||||
// banner summary regardless of when the changes were originally detected.
|
||||
const buCount = (anomaly?.classification?.bu_reassignment) || 10;
|
||||
const url = `${API_BASE}/ivanti/findings/bu-changes?limit=${buCount}`;
|
||||
const res = await fetch(url, { credentials: 'include' });
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
|
||||
Reference in New Issue
Block a user