Merge pull request #1438 from tchak/clean-up-moulinette

Cleanup rake task for public/private champ outage
This commit is contained in:
LeSim 2018-02-14 19:08:30 +01:00 committed by GitHub
commit 4d7be088f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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