Class: Newshound::Exceptions::SolidErrors

Inherits:
Base
  • Object
show all
Defined in:
lib/newshound/exceptions/solid_errors.rb

Instance Method Summary collapse

Instance Method Details

#format_for_banner(exception) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/newshound/exceptions/solid_errors.rb', line 22

def format_for_banner(exception)
  details = parse_exception_details(exception)

  {
    title: details[:title],
    message: details[:message].truncate(100),
    location: details[:location],
    time: exception.created_at.strftime("%I:%M %p")
  }
end

#format_for_report(exception, number) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/newshound/exceptions/solid_errors.rb', line 11

def format_for_report(exception, number)
  details = parse_exception_details(exception)

  <<~TEXT
    *#{number}. #{details[:title]}*
    • *Time:* #{exception.created_at.strftime("%I:%M %p")}
    #{format_controller(details)}
    #{format_message(details)}
  TEXT
end

#recent(time_range:, limit:) ⇒ Object



4
5
6
7
8
9
# File 'lib/newshound/exceptions/solid_errors.rb', line 4

def recent(time_range:, limit:)
  ::SolidErrors::Occurrence
    .where("created_at >= ?", time_range.ago)
    .order(created_at: :desc)
    .limit(limit)
end