Permalink
Browse files

Add task to recalculate search_results count

  • Loading branch information...
1 parent aeb176e commit d66d1bd7492c167de0114b68cad63f4e7c3171a4 Ricardo Panaggio committed Nov 10, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/tasks/search_results.rake
View
13 lib/tasks/search_results.rake
@@ -11,4 +11,17 @@ namespace :search_results do
end
end
end
+
+ desc "Recalculate votes count"
+ task :recalculate_votes_count => :environment do
+ SearchResult.find_each(:batch_size => 10_000) do |sr|
+ votes_count = sr.votes.count
+ if votes_count != sr.votes_count
+ sr.set(:votes_count => votes_count)
+ print 'C'
+ else
+ print '.'
+ end
+ end
+ end
end

0 comments on commit d66d1bd

Please sign in to comment.