Commit d3b6d0509b7fff27125eb32a2e439d80521c4aa8

Authored by Stephen Crosby
2 parents 8cf20c3e 0d5434b3
Exists in master and in 1 other branch production

Merge pull request #953 from stevecrozz/cache_app_on_notice

cache app on notice
app/models/error_report.rb
... ... @@ -65,6 +65,7 @@ class ErrorReport
65 65  
66 66 def make_notice
67 67 @notice = Notice.new(
  68 + app: app,
68 69 message: message,
69 70 error_class: error_class,
70 71 backtrace: backtrace,
... ...
app/models/notice.rb
... ... @@ -12,8 +12,9 @@ class Notice
12 12 field :framework
13 13 field :error_class
14 14 delegate :lines, :to => :backtrace, :prefix => true
15   - delegate :app, :problem, :to => :err
  15 + delegate :problem, :to => :err
16 16  
  17 + belongs_to :app
17 18 belongs_to :err
18 19 belongs_to :backtrace, :index => true
19 20  
... ...
db/migrate/20150926035420_cache_app_on_notice.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +class CacheAppOnNotice < Mongoid::Migration
  2 + def self.up
  3 + Notice.no_timeout.each do |n|
  4 + n.app_id = n.try(:err).try(:problem).try(:app_id)
  5 + n.save!
  6 + end
  7 + end
  8 +
  9 + def self.down
  10 + end
  11 +end
... ...
spec/fabricators/err_fabricator.rb
... ... @@ -4,6 +4,7 @@ Fabricator :err do
4 4 end
5 5  
6 6 Fabricator :notice do
  7 + app
7 8 err
8 9 message 'FooError: Too Much Bar'
9 10 backtrace
... ...