Class: RailsErrorDashboard::Queries::StormHistory
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Queries::StormHistory
- Defined in:
- lib/rails_error_dashboard/queries/storm_history.rb
Overview
Query: Storm protection episode history + active-storm lookup.
Read-only. Powers the /errors/storms page and the layout banner.
Constant Summary collapse
- RECENT_BANNER_WINDOW =
24.hours
Class Method Summary collapse
-
.banner_event ⇒ Object
Cheap banner lookup for the layout — one indexed query on the happy path (no active storm), two when a banner is showing.
- .call(limit: 50) ⇒ Object
Class Method Details
.banner_event ⇒ Object
Cheap banner lookup for the layout — one indexed query on the happy path (no active storm), two when a banner is showing.
28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_error_dashboard/queries/storm_history.rb', line 28 def self. return nil unless RailsErrorDashboard.configuration.enable_storm_protection return nil unless StormEvent.table_exists? StormEvent.active.recent_first.first || StormEvent.ended_within(RECENT_BANNER_WINDOW).recent_first.first rescue nil end |
.call(limit: 50) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rails_error_dashboard/queries/storm_history.rb', line 11 def self.call(limit: 50) return { active: nil, recent: nil, events: [] } unless StormEvent.table_exists? { active: StormEvent.active.recent_first.first, recent: StormEvent.ended_within(RECENT_BANNER_WINDOW).recent_first.first, events: StormEvent.recent_first.limit(limit).to_a } rescue => e RailsErrorDashboard::Logger.error( "[RailsErrorDashboard] StormHistory query failed: #{e.}" ) { active: nil, recent: nil, events: [] } end |