Class: RailsErrorDashboard::Queries::CriticalAlerts
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Queries::CriticalAlerts
- Defined in:
- lib/rails_error_dashboard/queries/critical_alerts.rb
Overview
Query: Fetch critical/high priority unresolved errors from the last hour Used on the overview dashboard to surface urgent issues
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(application_id: nil, limit: 10) ⇒ CriticalAlerts
constructor
A new instance of CriticalAlerts.
Constructor Details
#initialize(application_id: nil, limit: 10) ⇒ CriticalAlerts
Returns a new instance of CriticalAlerts.
12 13 14 15 |
# File 'lib/rails_error_dashboard/queries/critical_alerts.rb', line 12 def initialize(application_id: nil, limit: 10) @application_id = application_id @limit = limit end |
Class Method Details
.call(application_id: nil, limit: 10) ⇒ Object
8 9 10 |
# File 'lib/rails_error_dashboard/queries/critical_alerts.rb', line 8 def self.call(application_id: nil, limit: 10) new(application_id: application_id, limit: limit).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rails_error_dashboard/queries/critical_alerts.rb', line 17 def call scope = ErrorLog .where("occurred_at >= ?", 1.hour.ago) .where(resolved_at: nil) .where(priority_level: [ 3, 4 ]) scope = scope.where(application_id: @application_id) if @application_id.present? scope.order(occurred_at: :desc).limit(@limit) end |