2017-03-15 12:40:59 +01:00
|
|
|
class AutoArchiveProcedureWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
|
|
|
|
def perform(*args)
|
|
|
|
procedures_to_archive = Procedure.not_archived.where("auto_archive_on <= ?", Date.today)
|
|
|
|
|
|
|
|
procedures_to_archive.each do |p|
|
2017-05-26 18:59:21 +02:00
|
|
|
p.dossiers.state_en_construction.update_all(state: :received)
|
2017-03-15 12:40:59 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
procedures_to_archive.update_all(archived: true, auto_archive_on: nil)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|