Skip to content

Commit

Permalink
fixed logic to extend all alerts (opensearch-project#1033)
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan authored May 23, 2024
1 parent b8cb0ae commit e2841fa
Showing 1 changed file with 9 additions and 6 deletions.
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;
}
}

0 comments on commit e2841fa

Please sign in to comment.