Class: RailsPulse::SummaryJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- RailsPulse::SummaryJob
- Defined in:
- app/jobs/rails_pulse/summary_job.rb
Instance Method Summary collapse
-
#perform(target_hour = nil) ⇒ nil
Performs periodic summary aggregation (hourly/daily/weekly/monthly).
Instance Method Details
#perform(target_hour = nil) ⇒ nil
Performs periodic summary aggregation (hourly/daily/weekly/monthly)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/jobs/rails_pulse/summary_job.rb', line 6 def perform(target_hour = nil) target_hour ||= 1.hour.ago.beginning_of_hour # Always run hourly summary process_hourly_summary(target_hour) # Check if we should run daily summary (at the start of a new day) if midnight?(target_hour) process_daily_summary(target_hour.to_date - 1.day) # Check if we should run weekly summary (Monday at midnight) process_weekly_summary((target_hour.to_date - 1.week).beginning_of_week) if monday?(target_hour) # Check if we should run monthly summary (first day of month) process_monthly_summary((target_hour.to_date - 1.month).beginning_of_month) if first_of_month?(target_hour) end rescue StandardError => e log_error(e) raise end |