Change WeeklyOverviewWorker for delayed_job
This commit is contained in:
parent
f46330be1a
commit
e753c67ad6
3 changed files with 12 additions and 2 deletions
|
@ -67,6 +67,7 @@ Afin de générer la BDD de l'application, il est nécessaire d'éxécuter les c
|
|||
## Lancement des workers
|
||||
|
||||
Delayed::Job.enqueue(AutoArchiveProcedureWorker.new, cron: "* * * * *")
|
||||
Delayed::Job.enqueue(WeeklyOverviewWorker.new, cron: "0 8 * * 0")
|
||||
|
||||
## Exécution des tests (RSpec)
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class WeeklyOverviewWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(*args)
|
||||
Rails.logger.info("WeeklyOverviewWorker started at #{Time.now}")
|
||||
# Feature flipped to avoid mails in staging due to unprocessed dossier
|
||||
if Features.weekly_overview
|
||||
Gestionnaire.all
|
||||
|
@ -9,5 +8,12 @@ class WeeklyOverviewWorker
|
|||
.reject { |_, overview| overview.nil? }
|
||||
.each { |gestionnaire, overview| GestionnaireMailer.last_week_overview(gestionnaire, overview).deliver_now }
|
||||
end
|
||||
Rails.logger.info("WeeklyOverviewWorker ended at #{Time.now}")
|
||||
end
|
||||
|
||||
def queue_name
|
||||
"cron"
|
||||
end
|
||||
|
||||
handle_asynchronously :perform
|
||||
end
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WeeklyOverviewWorker, type: :worker do
|
||||
before { Delayed::Worker.delay_jobs = false }
|
||||
after { Delayed::Worker.delay_jobs = true }
|
||||
|
||||
describe 'perform' do
|
||||
let!(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:overview) { double('overview') }
|
||||
|
|
Loading…
Reference in a new issue