Commit 0072ec3d authored by syasonik's avatar syasonik

Use strong_memoize for alert ids

parent 82e4e2a9
...@@ -8,6 +8,8 @@ module EE ...@@ -8,6 +8,8 @@ module EE
module Dashboard module Dashboard
module Stages module Stages
class AlertsInserter < ::Gitlab::Metrics::Dashboard::Stages::BaseStage class AlertsInserter < ::Gitlab::Metrics::Dashboard::Stages::BaseStage
include ::Gitlab::Utils::StrongMemoize
def transform! def transform!
return if metrics_with_alerts.empty? return if metrics_with_alerts.empty?
...@@ -21,13 +23,13 @@ module EE ...@@ -21,13 +23,13 @@ module EE
private private
def metrics_with_alerts def metrics_with_alerts
return @metrics_with_alerts if @metrics_with_alerts strong_memoize(:metrics_with_alerts) do
alerts = ::Projects::Prometheus::AlertsFinder
alerts = ::Projects::Prometheus::AlertsFinder .new(project: project, environment: environment)
.new(project: project, environment: environment) .execute
.execute
@metrics_with_alerts = Set.new(alerts.map(&:prometheus_metric_id)) Set.new(alerts.map(&:prometheus_metric_id))
end
end end
def alert_path(metric_id, project, environment) def alert_path(metric_id, project, environment)
......
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