Class: Newshound::Exceptions::ExceptionTrack

Inherits:
Base
  • Object
show all
Defined in:
lib/newshound/exceptions/exception_track.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/exception_track.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/exception_track.rb', line 11

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

  "    *\#{number}. \#{details[:title]}*\n    \u2022 *Time:* \#{exception.created_at.strftime(\"%I:%M %p\")}\n    \#{format_controller(details)}\n    \#{format_message(details)}\n  TEXT\nend\n"

#recent(time_range:, limit:) ⇒ Object



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

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