Class: SolidStackWeb::ErrorFrequencyReport

Inherits:
Object
  • Object
show all
Defined in:
app/models/solid_stack_web/error_frequency_report.rb

Defined Under Namespace

Classes: Row

Constant Summary collapse

MESSAGE_LIMIT =
120

Instance Method Summary collapse

Instance Method Details

#groupsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/solid_stack_web/error_frequency_report.rb', line 7

def groups
  ::SolidQueue::FailedExecution
    .order(created_at: :desc)
    .each_with_object({}) do |execution, acc|
      key = [execution.exception_class.to_s, message_prefix(execution.message)]
      entry = acc[key] ||= { count: 0, sample_backtrace: nil }
      entry[:count] += 1
      entry[:sample_backtrace] ||= execution.backtrace
    end
    .map do |(exception_class, prefix), data|
      Row.new(
        exception_class:  exception_class,
        message_prefix:   prefix,
        count:            data[:count],
        sample_backtrace: data[:sample_backtrace]
      )
    end
    .sort_by { |row| -row.count }
end