Sha256: c453bdb376ff0338c9659b645a3eb1c19a5fb5e0e1db7960cbaeedea04cfbc0b

Contents?: true

Size: 539 Bytes

Versions: 36

Compression:

Stored size: 539 Bytes

Contents

require 'chronic_duration'

module Perus::Server
    class ActiveAlert < Sequel::Model
        many_to_one :alert
        many_to_one :system

        def severity
            alert.severity
        end

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

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

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
perus-0.1.23 lib/perus/server/models/active_alert.rb
perus-0.1.22 lib/perus/server/models/active_alert.rb
perus-0.1.21 lib/perus/server/models/active_alert.rb
perus-0.1.20 lib/perus/server/models/active_alert.rb
perus-0.1.19 lib/perus/server/models/active_alert.rb
perus-0.1.18 lib/perus/server/models/active_alert.rb
perus-0.1.17 lib/perus/server/models/active_alert.rb
perus-0.1.16 lib/perus/server/models/active_alert.rb
perus-0.1.15 lib/perus/server/models/active_alert.rb
perus-0.1.14 lib/perus/server/models/active_alert.rb
perus-0.1.13 lib/perus/server/models/active_alert.rb
perus-0.1.12 lib/perus/server/models/active_alert.rb
perus-0.1.11 lib/perus/server/models/active_alert.rb
perus-0.1.10 lib/perus/server/models/active_alert.rb
perus-0.1.9 lib/perus/server/models/active_alert.rb
perus-0.1.8 lib/perus/server/models/active_alert.rb