Class: PrometheusAlertEvent

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

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Class Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

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