diff --git a/lib/tasks/set_decrypted_private_body.rake b/lib/tasks/set_decrypted_private_body.rake index d387083fdb..e232be733c 100644 --- a/lib/tasks/set_decrypted_private_body.rake +++ b/lib/tasks/set_decrypted_private_body.rake @@ -3,15 +3,10 @@ namespace :decidim do desc "Set decrypted_private_body to existing extra fields" task set_decrypted_private_body: :environment do - extra_fields = Decidim::DecidimAwesome::ProposalExtraField.where(decrypted_private_body: nil).where.not(private_body: nil) - if extra_fields.any? - p "Extra fields to update: #{extra_fields.size}" - count = 0 - extra_fields.find_each do |extra_field| - extra_field.update(decrypted_private_body: extra_field.private_body.to_s) - count += 1 if extra_field.decrypted_private_body_previous_change.present? - end - p "Extra fields updated: #{count}" + if Rails.env.development? + PrivateBodyDecryptJob.perform_now + else + PrivateBodyDecryptJob.perform_later end end end