Class: RailsErrorDashboard::ErrorOccurrence
- Inherits:
-
ErrorLogsRecord
- Object
- ActiveRecord::Base
- ErrorLogsRecord
- RailsErrorDashboard::ErrorOccurrence
- Defined in:
- app/models/rails_error_dashboard/error_occurrence.rb
Overview
Tracks individual occurrences of errors for co-occurrence analysis
Each time an error is logged, we create an ErrorOccurrence record to track when it happened, who was affected, and what request caused it. This allows us to find errors that occur together in time windows.
Instance Method Summary collapse
-
#co_occurring_error_types(window_minutes: 5) ⇒ ActiveRecord::Relation
Find other error types that occurred near this occurrence.
-
#nearby_occurrences(window_minutes: 5) ⇒ ActiveRecord::Relation
Find occurrences within a time window around this occurrence.
Instance Method Details
#co_occurring_error_types(window_minutes: 5) ⇒ ActiveRecord::Relation
Find other error types that occurred near this occurrence
44 45 46 47 |
# File 'app/models/rails_error_dashboard/error_occurrence.rb', line 44 def co_occurring_error_types(window_minutes: 5) occurrence_ids = nearby_occurrences(window_minutes: window_minutes).pluck(:error_log_id) ErrorLog.where(id: occurrence_ids).where.not(error_type: error_log.error_type).distinct end |
#nearby_occurrences(window_minutes: 5) ⇒ ActiveRecord::Relation
Find occurrences within a time window around this occurrence
31 32 33 34 35 36 37 38 39 |
# File 'app/models/rails_error_dashboard/error_occurrence.rb', line 31 def nearby_occurrences(window_minutes: 5) window = window_minutes.minutes start_time = occurred_at - window end_time = occurred_at + window self.class .in_time_window(start_time, end_time) .where.not(id: id) # Exclude self end |