From a00309c7f47d92fc6942d9a83435ffb82e3b1663 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 14 Feb 2018 18:59:21 +0100 Subject: [PATCH] Cleanup rake task for public/private champ outage --- .../2018_02_14_clean_double_champ_private.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/tasks/2018_02_14_clean_double_champ_private.rake diff --git a/lib/tasks/2018_02_14_clean_double_champ_private.rake b/lib/tasks/2018_02_14_clean_double_champ_private.rake new file mode 100644 index 000000000..2b662e064 --- /dev/null +++ b/lib/tasks/2018_02_14_clean_double_champ_private.rake @@ -0,0 +1,14 @@ +namespace :'2018_02_14_clean_double_champ_private' do + task clean: :environment do + Champ.where(private: true).group_by(&:dossier_id).each_value do |champs| + seen = [] + champs.each do |champ| + if champ.type_de_champ_id.in?(seen) + champ.destroy + else + seen << champ.type_de_champ_id + end + end + end + end +end