Skip to content

Commit 617d71c

Browse files
author
Aaron Caldwell
committed
Carry active status through alert cycles and apply to docs without updates
1 parent de15f16 commit 617d71c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

x-pack/plugins/stack_alerts/server/alert_types/geo_containment/geo_containment.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ export const getGeoContainmentExecutor = (log: Logger) =>
153153
params.geoField
154154
);
155155

156-
// Cycle through new alert statuses and set active
157-
currLocationMap.forEach(({ location, shapeLocationId, dateInShape, docId }, entityName) => {
156+
// Combine newly active with previously active entries
157+
const allActiveEntriesMap: Map<string, LatestEntityLocation> = new Map([
158+
...Object.entries(state.prevLocationMap || {}),
159+
...currLocationMap,
160+
]);
161+
allActiveEntriesMap.forEach(({ location, shapeLocationId, dateInShape, docId }, entityName) => {
158162
const containingBoundaryName = shapesIdsNamesMap[shapeLocationId] || shapeLocationId;
159163
const context = {
160164
entityId: entityName,
@@ -166,13 +170,16 @@ export const getGeoContainmentExecutor = (log: Logger) =>
166170
containingBoundaryName,
167171
};
168172
const alertInstanceId = `${entityName}-${containingBoundaryName}`;
169-
if (shapeLocationId !== OTHER_CATEGORY) {
173+
if (shapeLocationId === OTHER_CATEGORY) {
174+
allActiveEntriesMap.delete(entityName);
175+
} else {
170176
services.alertInstanceFactory(alertInstanceId).scheduleActions(ActionGroupId, context);
171177
}
172178
});
173179

174180
return {
175181
shapesFilters,
176182
shapesIdsNamesMap,
183+
prevLocationMap: Object.fromEntries(allActiveEntriesMap),
177184
};
178185
};

0 commit comments

Comments
 (0)