Skip to content

Commit

Permalink
update rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbaraOliveira13 committed Oct 16, 2024
1 parent 0afa872 commit b6489aa
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/tasks/set_decrypted_private_body.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b6489aa

Please sign in to comment.