From 925edb01c7ef5ea810c2ad424758366941b76e2b Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Tue, 4 Jun 2019 10:37:05 +0200 Subject: [PATCH] Add OperationsSignatureJob --- README.md | 1 + app/jobs/operations_signature_job.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 app/jobs/operations_signature_job.rb diff --git a/README.md b/README.md index e8267b183..f113289d4 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later GestionnaireEmailNotificationJob.set(cron: "0 10 * * 1,2,3,4,5,6").perform_later PurgeUnattachedBlobsJob.set(cron: "0 0 * * *").perform_later + OperationsSignatureJob.set(cron: "0 6 * * *").perform_later ### Voir les emails envoyés en local diff --git a/app/jobs/operations_signature_job.rb b/app/jobs/operations_signature_job.rb new file mode 100644 index 000000000..092aec740 --- /dev/null +++ b/app/jobs/operations_signature_job.rb @@ -0,0 +1,15 @@ +class OperationsSignatureJob < ApplicationJob + queue_as :cron + + 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