From c37feba8d13f60f19e1944f8acd2bde2d0aea827 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 11 Mar 2021 10:23:10 +0100 Subject: [PATCH] Remove invalid geo areas --- ...10310170650_remove_invalid_geometries.rake | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/tasks/deployment/20210310170650_remove_invalid_geometries.rake diff --git a/lib/tasks/deployment/20210310170650_remove_invalid_geometries.rake b/lib/tasks/deployment/20210310170650_remove_invalid_geometries.rake new file mode 100644 index 000000000..ffa17dfef --- /dev/null +++ b/lib/tasks/deployment/20210310170650_remove_invalid_geometries.rake @@ -0,0 +1,21 @@ +namespace :after_party do + desc 'Deployment task: remove_invalid_geometries' + task remove_invalid_geometries: :environment do + puts "Running deploy task 'remove_invalid_geometries'" + + geo_areas = GeoArea.where(source: :selection_utilisateur) + progress = ProgressReport.new(geo_areas.count) + geo_areas.find_each do |geo_area| + if !geo_area.valid? + geo_area.destroy + end + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end