Class: ErrorsQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/maquina/solid_errors/templates/app/agents/errors_query.rb

Overview

Read-only queries over the Solid Errors store, shaped for agent consumption.

This layer NEVER writes. Resolution, retry, and discard stay with the human in the Backstage dashboards. Every context hash and job argument list passes through ErrorRedactor before leaving this class.

Failed background jobs reach Solid Errors through the Rails error reporter and carry the job class/arguments attached by ApplicationJob’s around_perform hook, so a single read here covers both request and job failures.

Column and association names (fingerprint, occurrences_count, recent_occurrence, parsed_backtrace) follow the solid_errors gem schema; confirm against your generated db/errors_schema.rb if you pin an unusual version.

Constant Summary collapse

DEFAULT_LIMIT =
25
TOP_LIMIT =
10
BACKTRACE_LIMIT =
50

Class Method Summary collapse

Class Method Details

.find(fingerprint) ⇒ Object



34
35
36
# File 'lib/generators/maquina/solid_errors/templates/app/agents/errors_query.rb', line 34

def find(fingerprint)
  detail(SolidErrors::Error.find_by!(fingerprint: fingerprint))
end

.top(limit: TOP_LIMIT) ⇒ Object



27
28
29
30
31
32
# File 'lib/generators/maquina/solid_errors/templates/app/agents/errors_query.rb', line 27

def top(limit: TOP_LIMIT)
  SolidErrors::Error.where(resolved_at: nil)
    .order(occurrences_count: :desc)
    .limit(limit)
    .map { |error| summarize(error) }
end

.unresolved(limit: DEFAULT_LIMIT) ⇒ Object



20
21
22
23
24
25
# File 'lib/generators/maquina/solid_errors/templates/app/agents/errors_query.rb', line 20

def unresolved(limit: DEFAULT_LIMIT)
  SolidErrors::Error.where(resolved_at: nil)
    .order(created_at: :desc)
    .limit(limit)
    .map { |error| summarize(error) }
end