2020-11-13 14:34:53 +01:00
|
|
|
class Cron::WeeklyOverviewJob < Cron::CronJob
|
2020-04-01 15:26:46 +02:00
|
|
|
self.schedule_expression = "every monday at 7 am"
|
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|
|
|
|
|
# NOTE: it's not exactly accurate because rate limit is not shared between jobs processes
|
|
|
|
Dolist::API.sleep_until_limit_reset if Dolist::API.near_rate_limit?
|
|
|
|
|
|
|
|
# mailer won't send anything if overview if empty
|
|
|
|
InstructeurMailer.last_week_overview(instructeur)&.deliver_later
|
2017-05-19 16:21:11 +02:00
|
|
|
end
|
2017-05-12 17:41:03 +02:00
|
|
|
end
|
|
|
|
end
|