Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,9 @@ def update_metric_alert(instance, scopes=None, description=None, enabled=None, t

# process action additions
if add_actions is not None:
for action in add_actions:
match = next(
(x for x in instance.actions if action.action_group_id.lower() == x.action_group_id.lower()), None
)
if match:
match.webhook_properties = action.webhook_properties
else:
instance.actions.append(action)
add_action_ids = {x.action_group_id.lower() for x in add_actions}
instance.actions = [x for x in instance.actions if x.action_group_id.lower() not in add_action_ids]
instance.actions.extend(add_actions)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use match for webhook_properties now? What does this change mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 'add_actions', the logical of original code is that if that action already exist then update its properties. Now I change the logic, if that action already exist, remove the old one and add the new one.


# process condition removals
if remove_conditions is not None:
Expand Down
Loading