We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
29 lines
781 B
Ruby
29 lines
781 B
Ruby
namespace :votes do
|
|
desc "Resets cached_votes_up counter to its latest value"
|
|
task reset_vote_counter: :environment do
|
|
models = [Proposal, Budget::Investment]
|
|
|
|
models.each do |model|
|
|
model.find_each do |resource|
|
|
resource.update_cached_votes
|
|
print "."
|
|
end
|
|
end
|
|
end
|
|
|
|
desc "Resets hot_score to its new value"
|
|
task reset_hot_score: :environment do
|
|
models = [Debate, Proposal, Legislation::Proposal]
|
|
|
|
models.each do |model|
|
|
print "Updating votes hot_score for #{model}s"
|
|
model.find_each do |resource|
|
|
new_hot_score = resource.calculate_hot_score
|
|
resource.update_columns(hot_score: new_hot_score, updated_at: Time.current)
|
|
end
|
|
puts " ✅ "
|
|
end
|
|
puts "Task finished 🎉 "
|
|
end
|
|
end
|