fix(after_party): use find_or_create_by to respect idempotency

instead of create!
This commit is contained in:
François Vantomme 2022-03-11 17:02:25 +01:00 committed by simon lehericey
parent 9d5db6e276
commit 021bdd4db6

View file

@ -6,7 +6,7 @@ namespace :after_party do
dossiers_termines = Dossier.state_termine
progress = ProgressReport.new(dossiers_termines.count)
dossiers_termines.find_each do |dossier|
dossier.traitements.create!(state: dossier.state, motivation: dossier.motivation, processed_at: dossier.processed_at)
dossier.traitements.find_or_create_by!(state: dossier.state, motivation: dossier.motivation, processed_at: dossier.processed_at)
progress.inc
end
progress.finish