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

21 lines
666 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Cron::OperationsSignatureJob < Cron::CronJob
2024-06-13 16:40:08 +02:00
self.schedule_expression = "every day at 06:00"
2019-06-04 10:37:05 +02:00
def perform(*args)
2024-04-18 11:18:53 +02:00
start_date = DossierOperationLog.where(bill_signature: nil).order(:executed_at).pick(:executed_at).beginning_of_day
2019-06-04 10:37:05 +02:00
last_midnight = Time.zone.today.beginning_of_day
2024-04-18 11:18:53 +02:00
while start_date < last_midnight
operations = DossierOperationLog
2024-04-18 11:19:51 +02:00
.select(:id, :digest)
2024-04-18 11:18:53 +02:00
.where(executed_at: start_date...start_date.tomorrow, bill_signature: nil)
BillSignatureService.sign_operations(operations, start_date) if operations.present?
start_date = start_date.tomorrow
2019-06-04 10:37:05 +02:00
end
end
end