notice_refingerprinter.rb
1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class NoticeRefingerprinter
LOG_EVERY = 100
LOG_ITR = '%.1f%% complete, %i notice(s) remaining'
LOG_START = 'Regenerating notice fingerprints for %i notices'
def self.run
count = Notice.count
puts format(LOG_START, count)
Notice.no_timeout.each_with_index do |notice, index|
refingerprint(notice)
next unless (index + 1) % LOG_EVERY == 0
puts format(LOG_ITR, (index * 100 / count), count - index)
end
puts 'Finished generating notice fingerprints'
puts 'Destroying orphaned err records'
Err.each { |e| e.destroy if e.notices.size == 0 }
puts 'Finished destroying orphaned err records'
end
def self.refingerprint(notice)
app = notice.app
notice.err = app.find_or_create_err!(
error_class: notice.error_class,
environment: notice.environment_name,
fingerprint: app.notice_fingerprinter.generate(app.api_key, notice, notice.backtrace)
)
notice.save!
end
def self.puts(*args)
Rails.logger.info(*args)
end
end