demarches-normaliennes/app/workers/auto_archive_procedure_worker.rb
gregoirenovel 67d0fb5ddc Further refactor of AutoArchiveProcedureWorker
Call received! so that validation and save
callbacks are called.

Previously, we wouldn’t have update the
received_at date
2017-06-08 15:06:01 +02:00

13 lines
341 B
Ruby

class AutoArchiveProcedureWorker
include Sidekiq::Worker
def perform(*args)
Procedure.not_archived.where("auto_archive_on <= ?", Date.today).each do |procedure|
procedure.dossiers.state_en_construction.each do |dossier|
dossier.received!
end
procedure.update_attributes!(archived: true)
end
end
end