class ExceptionHunter::ErrorReaper

Class in charge of disposing of stale errors as specified in the {ExceptionHunter::Config}.

Public Class Methods

purge(stale_time: Config.errors_stale_time) click to toggle source

Destroys all stale errors.

@example

ErrorReaper.purge(stale_time: 30.days)

@param [Numeric] stale_time considered when destroying errors @return [void]

# File lib/exception_hunter/error_reaper.rb, line 12
def purge(stale_time: Config.errors_stale_time)
  ActiveRecord::Base.transaction do
    Error.with_occurrences_before(Date.today - stale_time).destroy_all
    ErrorGroup.without_errors.destroy_all
  end
end