summaryrefslogtreecommitdiff
path: root/app/presenters/prometheus_alert_presenter.rb
blob: 776e2baebddb7c8789d03af37c0c4fa5d0bbc33d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

class PrometheusAlertPresenter < Gitlab::View::Presenter::Delegated
  presents ::PrometheusAlert, as: :prometheus_alert

  def humanized_text
    operator_text =
      case prometheus_alert.operator
      when 'lt' then s_('PrometheusAlerts|is less than')
      when 'eq' then s_('PrometheusAlerts|is equal to')
      when 'gt' then s_('PrometheusAlerts|exceeded')
      end

    "#{operator_text} #{prometheus_alert.threshold}#{prometheus_alert.prometheus_metric.unit}"
  end
end