Class: PrometheusAlertEvent

Inherits:
ApplicationRecord show all
Includes:
AlertEventLifecycle
Defined in:
app/models/prometheus_alert_event.rb

Class Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.find_by_payload_key(payload_key) ⇒ Object


30
31
32
# File 'app/models/prometheus_alert_event.rb', line 30

def self.find_by_payload_key(payload_key)
  find_by(payload_key: payload_key)
end

.find_or_initialize_by_payload_key(project, alert, payload_key) ⇒ Object


26
27
28
# File 'app/models/prometheus_alert_event.rb', line 26

def self.find_or_initialize_by_payload_key(project, alert, payload_key)
  find_or_initialize_by(project: project, prometheus_alert: alert, payload_key: payload_key)
end

.last_by_project_idObject


21
22
23
24
# File 'app/models/prometheus_alert_event.rb', line 21

def self.last_by_project_id
  ids = select(arel_table[:id].maximum.as('id')).group(:project_id).map(&:id)
  with_prometheus_alert.find(ids)
end

.status_value_for(name) ⇒ Object


34
35
36
# File 'app/models/prometheus_alert_event.rb', line 34

def self.status_value_for(name)
  state_machines[:status].states[name].value
end