demarches-normaliennes/app/jobs/cron/weekly_overview_job.rb

14 lines
464 B
Ruby
Raw Normal View History

class Cron::WeeklyOverviewJob < Cron::CronJob
2024-06-13 16:40:08 +02:00
self.schedule_expression = "every monday at 04:05"
2017-10-03 16:19:25 +02:00
def perform
# Feature flipped to avoid mails in staging due to unprocessed dossier
return unless Rails.application.config.ds_weekly_overview
Instructeur.find_each do |instructeur|
# mailer won't send anything if overview if empty
InstructeurMailer.last_week_overview(instructeur)&.deliver_later(wait: rand(0..3.hours))
end
end
end