cc95216672
If the loop failed, we wouldn’t update the archived attribute for procedures for which the folders were archived. That would have caused to re-run the task for procedures for which the task had already been run.
11 lines
316 B
Ruby
11 lines
316 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.update_all(state: :received)
|
|
|
|
procedure.update_attributes!(archived: true)
|
|
end
|
|
end
|
|
end
|