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
|
# File 'app/jobs/rails_pulse/summary_job.rb', line 3
def perform(target_hour = nil)
target_hour ||= 1.hour.ago.beginning_of_hour
process_hourly_summary(target_hour)
if target_hour.hour == 0
process_daily_summary(target_hour.to_date - 1.day)
if target_hour.wday == 1
process_weekly_summary((target_hour.to_date - 1.week).beginning_of_week)
end
if target_hour.day == 1
process_monthly_summary((target_hour.to_date - 1.month).beginning_of_month)
end
end
rescue => e
Rails.logger.error "[RailsPulse] Summary job failed: #{e.message}"
Rails.logger.error e.backtrace.join("\n")
raise
end
|