Merge pull request #9044 from tchak/fix-after-party-task2

fix(after_party): type_de_champ can be nil
This commit is contained in:
Paul Chavard 2023-05-12 21:51:03 +02:00 committed by GitHub
commit a6cbd77ad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,8 +25,10 @@ namespace :after_party do
bad_champs = dossier.champs.filter { !dossier.revision_id.in?(_1.type_de_champ.revisions.ids) }
bad_champs.each do |champ|
type_de_champ = dossier.revision.types_de_champ.find { _1.stable_id == champ.stable_id }
puts "Updating champ #{champ.id} on dossier #{dossier.id} from #{champ.type_de_champ_id} to type_de_champ #{type_de_champ.id}"
champ.update_column(:type_de_champ_id, type_de_champ.id)
if type_de_champ.present?
puts "Updating champ #{champ.id} on dossier #{dossier.id} from #{champ.type_de_champ_id} to type_de_champ #{type_de_champ.id}"
champ.update_column(:type_de_champ_id, type_de_champ.id)
end
end
end