Files
nairobi/lib/tasks/spending_proposals.rake
Juanjo Bazán 948436f130 adds rake task to touch all spending proposals
(it triggers the recalculating of the tsvector for pg_search)
2016-03-30 12:11:15 +02:00

20 lines
687 B
Ruby

namespace :spending_proposals do
desc "Sends an email to the authors of unfeasible spending proposals"
task send_unfeasible_emails: :environment do
SpendingProposal.find_each do |spending_propsal|
if spending_propsal.unfeasible_email_pending?
spending_propsal.send_unfeasible_email
puts "email sent for proposal #{spending_propsal.title}"
else
puts "this proposal is feasible: #{spending_propsal.title}"
end
end
end
desc "Updates all spending proposals to recalculate their tsv column"
task touch: :environment do
SpendingProposal.find_in_batches do |spending_propsal|
spending_propsal.each(&:save)
end
end
end