From 28f9bd62d1747e42f44535c15df61b3ffd73dca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Vantomme?= Date: Fri, 11 Mar 2022 17:32:09 +0100 Subject: [PATCH] fix(after_party): use find_or_create_by to respect idempotency --- .../deployment/20200813111957_fix_geo_areas_geometry.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake b/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake index 3969494b9..53a4c718b 100644 --- a/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake +++ b/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake @@ -18,7 +18,7 @@ namespace :after_party do geometry_collections.find_each do |geometry_collection| geometry_collection.geometry['geometries'].each do |geometry| if valid_geometry?(geometry) - geometry_collection.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') + geometry_collection.champ.geo_areas.find_or_create_by!(geometry: geometry, source: 'selection_utilisateur') end end @@ -36,7 +36,7 @@ namespace :after_party do } if valid_geometry?(geometry) - multi_line_string.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') + multi_line_string.champ.geo_areas.find_or_create_by!(geometry: geometry, source: 'selection_utilisateur') end end @@ -54,7 +54,7 @@ namespace :after_party do } if valid_geometry?(geometry) - multi_polygon.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') + multi_polygon.champ.geo_areas.find_or_create_by!(geometry: geometry, source: 'selection_utilisateur') end end