Add rake task to calculate cached voted score

Run this task it's only necessary if already existing legislation proposals in DB.
This commit is contained in:
decabeza
2019-02-13 11:35:21 +01:00
parent 6b62ba0e91
commit fbbf092015

View File

@@ -0,0 +1,10 @@
namespace :legislation_proposals do
desc "Calculate cached votes score for existing legislation proposals"
task calculate_cached_votes_score: :environment do
Legislation::Proposal.find_each do |p|
p.update_column(:cached_votes_score, p.cached_votes_up - p.cached_votes_down)
print "."
end
puts "\nTask finished 🎉"
end
end