Class: RailsErrorDashboard::Queries::DashboardStats

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/queries/dashboard_stats.rb

Overview

Query: Fetch dashboard statistics This is a read operation that aggregates error data for the dashboard

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



8
9
10
# File 'lib/rails_error_dashboard/queries/dashboard_stats.rb', line 8

def self.call
  new.call
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rails_error_dashboard/queries/dashboard_stats.rb', line 12

def call
  {
    total_today: ErrorLog.where("occurred_at >= ?", Time.current.beginning_of_day).count,
    total_week: ErrorLog.where("occurred_at >= ?", 7.days.ago).count,
    total_month: ErrorLog.where("occurred_at >= ?", 30.days.ago).count,
    unresolved: ErrorLog.unresolved.count,
    resolved: ErrorLog.resolved.count,
    by_platform: ErrorLog.group(:platform).count,
    top_errors: top_errors,
    #  Trend visualizations
    errors_trend_7d: errors_trend_7d,
    errors_by_severity_7d: errors_by_severity_7d,
    spike_detected: spike_detected?,
    spike_info: spike_info
  }
end