Use base CronJob

This commit is contained in:
Paul Chavard 2020-03-28 16:49:40 +01:00
parent 5005c54891
commit 742cc15209
15 changed files with 30 additions and 30 deletions

View file

@ -1,5 +1,5 @@
class Administrateurs::ActivateBeforeExpirationJob < ApplicationJob
queue_as :cron
class AdministrateurActivateBeforeExpirationJob < CronJob
self.cron_expression = "0 8 * * *"
def perform(*args)
Administrateur

View file

@ -1,5 +1,5 @@
class AutoArchiveProcedureJob < ApplicationJob
queue_as :cron
class AutoArchiveProcedureJob < CronJob
self.cron_expression = "* * * * *"
def perform(*args)
Procedure.publiees.where("auto_archive_on <= ?", Time.zone.today).each do |procedure|

View file

@ -1,5 +1,5 @@
class DeclarativeProceduresJob < ApplicationJob
queue_as :cron
class DeclarativeProceduresJob < CronJob
self.cron_expression = "* * * * *"
def perform(*args)
Procedure.declarative.find_each(&:process_dossiers!)

View file

@ -1,5 +1,5 @@
class DiscardedDossiersDeletionJob < ApplicationJob
queue_as :cron
class DiscardedDossiersDeletionJob < CronJob
self.cron_expression = "0 7 * * *"
def perform(*args)
Dossier.discarded_brouillon_expired.destroy_all

View file

@ -1,5 +1,5 @@
class ExpiredDossiersDeletionJob < ApplicationJob
queue_as :cron
class ExpiredDossiersDeletionJob < CronJob
self.cron_expression = "0 7 * * *"
def perform(*args)
ExpiredDossiersDeletionService.process_expired_dossiers_brouillon

View file

@ -1,5 +1,5 @@
class FindDubiousProceduresJob < ApplicationJob
queue_as :cron
class FindDubiousProceduresJob < CronJob
self.cron_expression = "0 0 * * *"
FORBIDDEN_KEYWORDS = [
'NIR', 'NIRPP', 'race', 'religion',

View file

@ -1,5 +1,5 @@
class InstructeurEmailNotificationJob < ApplicationJob
queue_as :cron
class InstructeurEmailNotificationJob < CronJob
self.cron_expression = "0 10 * * MON-FRI"
def perform(*args)
NotificationService.send_instructeur_email_notification

View file

@ -1,5 +1,5 @@
class NotifyDraftNotSubmittedJob < ApplicationJob
queue_as :cron
class NotifyDraftNotSubmittedJob < CronJob
self.cron_expression = "0 7 * * *"
def perform(*args)
Dossier.notify_draft_not_submitted

View file

@ -1,5 +1,5 @@
class OperationsSignatureJob < ApplicationJob
queue_as :cron
class OperationsSignatureJob < CronJob
self.cron_expression = "0 6 * * *"
def perform(*args)
last_midnight = Time.zone.today.beginning_of_day

View file

@ -1,5 +1,5 @@
class PurgeStaleExportsJob < ApplicationJob
queue_as :cron
class PurgeStaleExportsJob < CronJob
self.cron_expression = "*/5 * * * *"
def perform
Export.stale.destroy_all

View file

@ -1,5 +1,5 @@
class PurgeUnattachedBlobsJob < ApplicationJob
queue_as :cron
class PurgeUnattachedBlobsJob < CronJob
self.cron_expression = "0 0 * * *"
def perform(*args)
ActiveStorage::Blob.unattached

View file

@ -1,5 +1,5 @@
class UpdateAdministrateurUsageStatisticsJob < ApplicationJob
queue_as :cron
class UpdateAdministrateurUsageStatisticsJob < CronJob
self.cron_expression = "0 10 * * *"
def perform
AdministrateurUsageStatisticsService.new.update_administrateurs

View file

@ -1,5 +1,5 @@
class WarnExpiringDossiersJob < ApplicationJob
queue_as :cron
class WarnExpiringDossiersJob < CronJob
self.cron_expression = "0 0 1 * *"
def perform(*args)
expiring, expired = Dossier

View file

@ -1,5 +1,5 @@
class WeeklyOverviewJob < ApplicationJob
queue_as :cron
class WeeklyOverviewJob < CronJob
self.cron_expression = "0 7 * * MON"
def perform(*args)
# Feature flipped to avoid mails in staging due to unprocessed dossier

View file

@ -1,12 +1,12 @@
require 'rails_helper'
RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
RSpec.describe AdministrateurActivateBeforeExpirationJob, type: :job do
describe 'perform' do
let(:administrateur) { create(:administrateur) }
let(:user) { administrateur.user }
let(:mailer_double) { double('mailer', deliver_later: true) }
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
subject { AdministrateurActivateBeforeExpirationJob.perform_now }
before do
Timecop.freeze(Time.zone.local(2018, 03, 20))