2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-01-26 15:33:42 +01:00
|
|
|
namespace :hotfix do
|
|
|
|
desc 'Fix dossiers attestations'
|
|
|
|
task dossiers_attestations: :environment do
|
|
|
|
dossiers = Dossier
|
|
|
|
.joins(procedure: :attestation_template)
|
2023-04-19 12:03:08 +02:00
|
|
|
.where.missing(:attestation)
|
|
|
|
.where(attestation_templates: { activated: true }, state: "accepte")
|
2022-01-26 15:33:42 +01:00
|
|
|
.where("dossiers.processed_at > '2022-01-24'")
|
|
|
|
progress = ProgressReport.new(dossiers.count)
|
|
|
|
|
|
|
|
dossiers.find_each do |dossier|
|
|
|
|
if dossier.attestation.blank?
|
|
|
|
dossier.attestation = dossier.build_attestation
|
|
|
|
dossier.save!
|
|
|
|
end
|
|
|
|
progress.inc
|
|
|
|
end
|
|
|
|
progress.finish
|
|
|
|
end
|
|
|
|
end
|