Class: RailsErrorDashboard::StormEvent

Inherits:
ErrorLogsRecord
  • Object
show all
Defined in:
app/models/rails_error_dashboard/storm_event.rb

Overview

One row per storm-protection episode (per process). Powers the dashboard banner and the storm history page. Counts are exact, not extrapolated. Inherits ErrorLogsRecord so separate-database routing applies.

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/rails_error_dashboard/storm_event.rb', line 14

def active?
  ended_at.nil?
end

#duration_secondsObject



18
19
20
21
22
# File 'app/models/rails_error_dashboard/storm_event.rb', line 18

def duration_seconds
  return nil unless ended_at

  (ended_at - started_at).round
end

#top_fingerprints_listArray<Hash>

Returns top fingerprints by count, [] when absent/corrupt.

Returns:

  • (Array<Hash>)

    top fingerprints by count, [] when absent/corrupt



25
26
27
28
29
30
31
32
# File 'app/models/rails_error_dashboard/storm_event.rb', line 25

def top_fingerprints_list
  return [] if top_fingerprints.blank?

  parsed = JSON.parse(top_fingerprints)
  parsed.is_a?(Array) ? parsed : []
rescue JSON::ParserError
  []
end