Commit 5abc0108 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '207080-combine-send-email-calls' into 'master'

Move send_email? to IncidentManagement::Settings

Closes #207080

See merge request gitlab-org/gitlab!37808
parents b341cb26 06f04b57
# frozen_string_literal: true # frozen_string_literal: true
module IncidentManagement module IncidentManagement
module Settings module Settings
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
delegate :send_email?, to: :incident_management_setting
def incident_management_setting def incident_management_setting
strong_memoize(:incident_management_setting) do strong_memoize(:incident_management_setting) do
project.incident_management_setting || project.incident_management_setting ||
......
...@@ -58,10 +58,6 @@ module Projects ...@@ -58,10 +58,6 @@ module Projects
AlertManagement::Alert.not_resolved.for_fingerprint(project, fingerprint).first AlertManagement::Alert.not_resolved.for_fingerprint(project, fingerprint).first
end end
def send_email?
incident_management_setting.send_email?
end
def process_incident_issues(alert) def process_incident_issues(alert)
return if alert.issue return if alert.issue
......
...@@ -42,10 +42,6 @@ module Projects ...@@ -42,10 +42,6 @@ module Projects
Gitlab::Utils::DeepSize.new(params).valid? Gitlab::Utils::DeepSize.new(params).valid?
end end
def send_email?
incident_management_setting.send_email && firings.any?
end
def firings def firings
@firings ||= alerts_by_status('firing') @firings ||= alerts_by_status('firing')
end end
...@@ -125,6 +121,8 @@ module Projects ...@@ -125,6 +121,8 @@ module Projects
end end
def send_alert_email def send_alert_email
return unless firings.any?
notification_service notification_service
.async .async
.prometheus_alerts_fired(project, firings) .prometheus_alerts_fired(project, firings)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment