Merge branch 'dev'

This commit is contained in:
Frederic Merizen 2018-03-09 16:02:31 +01:00
commit e5ca4b9176

View file

@ -5,12 +5,17 @@ namespace :'2018_03_06_clean_html_textareas' do
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
include HtmlToStringHelper include HtmlToStringHelper
types_de_champ = TypeDeChamp.joins(:champ) champs = Champ.joins(:type_de_champ)
.where(type_champ: "textarea") .where(types_de_champ: { type_champ: "textarea" })
.where("champs.value LIKE '%<%'") .where("value LIKE '%<%'")
types_de_champ.find_each do |tdc| total = champs.count
tdc.champ.each { |c| c.update_column(:value, html_to_string(c.value)) }
champs.find_each(batch_size: 100).with_index do |c, i|
if (i % 100) == 0
print "Champ #{i}/#{total}\n"
end
c.update_column(:value, html_to_string(c.value))
end end
end end
end end