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
28
29
30
31
32
33
34
35
# 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,
    # New metrics for Overview dashboard
    error_rate: error_rate,
    affected_users_today: affected_users_today,
    affected_users_yesterday: affected_users_yesterday,
    affected_users_change: affected_users_change,
    trend_percentage: trend_percentage,
    trend_direction: trend_direction,
    top_errors_by_impact: top_errors_by_impact
  }
end