2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-11-10 12:05:35 +01:00
|
|
|
namespace :after_party do
|
|
|
|
desc 'Deployment task: set_dossiers_processed_at'
|
|
|
|
task set_dossiers_processed_at: :environment do
|
|
|
|
puts "Running deploy task 'set_dossiers_processed_at'"
|
|
|
|
|
2021-12-07 16:15:43 +01:00
|
|
|
dossiers = Dossier.with_discarded.state_termine.includes(:traitement)
|
2021-11-10 12:05:35 +01:00
|
|
|
progress = ProgressReport.new(dossiers.count)
|
|
|
|
|
|
|
|
dossiers.find_each do |dossier|
|
2021-12-07 13:36:59 +01:00
|
|
|
if dossier.read_attribute(:processed_at) != dossier.traitement.processed_at
|
2021-11-10 12:05:35 +01:00
|
|
|
dossier.update_column(:processed_at, dossier.traitement.processed_at)
|
|
|
|
end
|
|
|
|
progress.inc
|
|
|
|
end
|
|
|
|
progress.finish
|
|
|
|
|
|
|
|
# Update task as completed. If you remove the line below, the task will
|
|
|
|
# run with every deploy (or every time you call after_party:run).
|
|
|
|
AfterParty::TaskRecord
|
|
|
|
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
|
|
|
end
|
|
|
|
end
|