Class: ErrorLens::ErrorOccurrence

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/error_lens/error_occurrence.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.purge_older_than(days = 60) ⇒ Object



11
12
13
# File 'app/models/error_lens/error_occurrence.rb', line 11

def self.purge_older_than(days = 60)
  where("occurred_at < ?", days.days.ago).delete_all
end

Instance Method Details

#app_backtraceObject



39
40
41
# File 'app/models/error_lens/error_occurrence.rb', line 39

def app_backtrace
  parsed_backtrace.select { |line| line.start_with?(Rails.root.to_s) }
end

#parsed_backtraceObject



15
16
17
18
19
# File 'app/models/error_lens/error_occurrence.rb', line 15

def parsed_backtrace
  JSON.parse(backtrace || "[]")
rescue JSON::ParserError
  []
end

#parsed_job_argsObject



27
28
29
30
31
# File 'app/models/error_lens/error_occurrence.rb', line 27

def parsed_job_args
  JSON.parse(job_args || "[]")
rescue JSON::ParserError
  []
end

#parsed_parametersObject



21
22
23
24
25
# File 'app/models/error_lens/error_occurrence.rb', line 21

def parsed_parameters
  JSON.parse(parameters || "{}")
rescue JSON::ParserError
  {}
end

#parsed_request_headersObject



33
34
35
36
37
# File 'app/models/error_lens/error_occurrence.rb', line 33

def parsed_request_headers
  JSON.parse(request_headers || "{}")
rescue JSON::ParserError
  {}
end

#sidekiq?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/error_lens/error_occurrence.rb', line 47

def sidekiq?
  source == "sidekiq"
end

#web?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/error_lens/error_occurrence.rb', line 43

def web?
  source == "web"
end