2020-11-13 14:34:53 +01:00
|
|
|
class Cron::OperationsSignatureJob < Cron::CronJob
|
2020-04-01 15:26:46 +02:00
|
|
|
self.schedule_expression = "every day at 6 am"
|
2019-06-04 10:37:05 +02:00
|
|
|
|
|
|
|
def perform(*args)
|
|
|
|
last_midnight = Time.zone.today.beginning_of_day
|
|
|
|
operations_by_day = BillSignatureService.grouped_unsigned_operation_until(last_midnight)
|
|
|
|
operations_by_day.each do |day, operations|
|
|
|
|
begin
|
|
|
|
BillSignatureService.sign_operations(operations, day)
|
|
|
|
rescue
|
|
|
|
raise # let errors show up on Sentry and delayed_jobs
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|