Skip to content

Commit

Permalink
[Alerting] optimize calculation of unmuted alert instances
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuellr committed Sep 21, 2020
1 parent 4b49e5a commit 448a6a5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions x-pack/plugins/alerts/server/task_runner/task_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { pickBy, mapValues, omit, without } from 'lodash';
import { pickBy, mapValues, omitBy, without } from 'lodash';
import { Logger, KibanaRequest } from '../../../../../src/core/server';
import { TaskRunnerContext } from './task_runner_factory';
import { ConcreteTaskInstance } from '../../../task_manager/server';
Expand Down Expand Up @@ -228,7 +228,10 @@ export class TaskRunner {
});

if (!muteAll) {
const enabledAlertInstances = omit(instancesWithScheduledActions, ...mutedInstanceIds);
const mutedInstanceIdsSet = new Set(mutedInstanceIds);
const enabledAlertInstances = omitBy(instancesWithScheduledActions, (val, key) =>
mutedInstanceIdsSet.has(key)
);

await Promise.all(
Object.entries(enabledAlertInstances)
Expand Down

0 comments on commit 448a6a5

Please sign in to comment.