Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] When sending partial alerts results extend them with the detector name and id as well #1069

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions public/store/AlertsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export class AlertsStore {
}

if (getAlertsRes.ok) {
onPartialAlertsFetched?.(getAlertsRes.response.alerts)
allAlerts = allAlerts.concat(getAlertsRes.response.alerts);
alertsCount = getAlertsRes.response.alerts.length;
const alerts = this.extendAlerts(getAlertsRes.response.alerts, detectorId, detectorName);
onPartialAlertsFetched?.(alerts);
allAlerts = allAlerts.concat(alerts);
alertsCount = alerts.length;
} else {
alertsCount = 0;
errorNotificationToast(this.notifications, 'retrieve', 'alerts', getAlertsRes.error);
Expand All @@ -59,7 +60,11 @@ export class AlertsStore {
alertsCount === maxAlertsReturned
);

allAlerts = allAlerts.map((alert) => {
return allAlerts;
}

private extendAlerts(allAlerts: any[], detectorId: string, detectorName: string) {
return allAlerts.map((alert) => {
if (!alert.detector_id) {
alert.detector_id = detectorId;
}
Expand All @@ -69,7 +74,5 @@ export class AlertsStore {
detectorName: detectorName,
};
});

return allAlerts;
}
}
Loading