2018-06-12 18:17:37 +02:00
|
|
|
require Rails.root.join("lib", "tasks", "task_helper")
|
|
|
|
|
2018-06-07 16:03:37 +02:00
|
|
|
namespace :'2018_06_05_resend_attestations' do
|
2018-06-05 17:00:22 +02:00
|
|
|
task set: :environment do
|
|
|
|
procedure = Procedure.find(4247)
|
|
|
|
dossiers = procedure.dossiers.includes(:attestation).where(state: 'accepte').select do |d|
|
|
|
|
d.processed_at < procedure.attestation_template.updated_at
|
|
|
|
end
|
|
|
|
|
|
|
|
dossiers.each do |dossier|
|
|
|
|
attestation = dossier.attestation
|
|
|
|
attestation.destroy
|
|
|
|
|
|
|
|
dossier.attestation = dossier.build_attestation
|
|
|
|
|
2018-06-07 17:23:12 +02:00
|
|
|
ResendAttestationMailer.resend_attestation(dossier).deliver_later
|
2018-06-12 18:17:37 +02:00
|
|
|
rake_puts "Email envoyé à #{dossier.user.email} pour le dossier #{dossier.id}"
|
2018-06-05 17:00:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|