From b6489aac61a70f3e79d9ed4f707ff2d3cfb5c87c Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Wed, 16 Oct 2024 12:25:25 +0200 Subject: [PATCH] update rake task --- lib/tasks/set_decrypted_private_body.rake | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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