Class: ErrorRadar::Api::StatsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/error_radar/api/stats_controller.rb

Overview

GET /api/stats — summary counts for dashboards, CI gates, uptime monitors.

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/error_radar/api/stats_controller.rb', line 7

def show
  render json: {
    total:       ErrorLog.count,
    open:        ErrorLog.where(status: ErrorLog.statuses[:open]).count,
    in_progress: ErrorLog.where(status: ErrorLog.statuses[:in_progress]).count,
    resolved:    ErrorLog.where(status: ErrorLog.statuses[:resolved]).count,
    ignored:     ErrorLog.where(status: ErrorLog.statuses[:ignored]).count,
    unresolved:  ErrorLog.unresolved.count,
    by_severity: ErrorLog.group(:severity).count,
    by_category: ErrorLog.group(:category).count,
    generated_at: Time.current.iso8601
  }
end