From 0d628bb96b2e0f374cefe7854e46129907f5eaba Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 14 Apr 2020 13:10:47 +0200 Subject: [PATCH] Task to split GeoArea with selection utilisateur in multiple polygons --- ...split_geo_area_selection_multipolygons.rake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/tasks/deployment/20200414104712_split_geo_area_selection_multipolygons.rake diff --git a/lib/tasks/deployment/20200414104712_split_geo_area_selection_multipolygons.rake b/lib/tasks/deployment/20200414104712_split_geo_area_selection_multipolygons.rake new file mode 100644 index 000000000..930a650aa --- /dev/null +++ b/lib/tasks/deployment/20200414104712_split_geo_area_selection_multipolygons.rake @@ -0,0 +1,18 @@ +namespace :after_party do + desc 'Deployment task: split_geo_area_selection_multipolygons' + task split_geo_area_selection_multipolygons: :environment do + puts "Running deploy task 'split_geo_area_selection_multipolygons'" + + Champs::CarteChamp.where.not(value: ['', '[]']).includes(:geo_areas).find_each do |champ| + if champ.send(:selection_utilisateur_legacy?) + legacy_selection_utilisateur = champ.selections_utilisateur.first + champ.send(:legacy_selections_utilisateur).each do |area| + champ.geo_areas << area + end + legacy_selection_utilisateur.destroy + end + end + + AfterParty::TaskRecord.create version: '20200414104712' + end +end