Class: Perus::Server::ActiveAlert

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/perus/server/models/active_alert.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add(alert, system) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/perus/server/models/active_alert.rb', line 16

def self.add(alert, system)
    ActiveAlert.create(
        system_id: system.id,
        alert_id: alert.id,
        timestamp: Time.now.to_i
    )
end

Instance Method Details

#active_forObject



12
13
14
# File 'lib/perus/server/models/active_alert.rb', line 12

def active_for
    ChronicDuration.output(Time.now.to_i - timestamp, format: :short)
end

#severityObject



8
9
10
# File 'lib/perus/server/models/active_alert.rb', line 8

def severity
    alert.severity
end