2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-11-13 14:34:53 +01:00
|
|
|
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
|
|
|
|
2023-03-02 19:01:14 +01:00
|
|
|
def perform
|
2017-05-19 16:21:11 +02:00
|
|
|
# Feature flipped to avoid mails in staging due to unprocessed dossier
|
2023-03-02 19:01:14 +01:00
|
|
|
return unless Rails.application.config.ds_weekly_overview
|
|
|
|
|
|
|
|
Instructeur.find_each do |instructeur|
|
|
|
|
# mailer won't send anything if overview if empty
|
2023-06-26 15:23:59 +02:00
|
|
|
InstructeurMailer.last_week_overview(instructeur)&.deliver_later(wait: rand(0..3.hours))
|
2017-05-19 16:21:11 +02:00
|
|
|
end
|
2017-05-12 17:41:03 +02:00
|
|
|
end
|
|
|
|
end
|