Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add task to recalculate search_results count

  • Loading branch information...
commit d66d1bd7492c167de0114b68cad63f4e7c3171a4 1 parent aeb176e
authored November 10, 2011

Showing 1 changed file with 13 additions and 0 deletions. Show diff stats Hide diff stats

  1. 13  lib/tasks/search_results.rake
13  lib/tasks/search_results.rake
@@ -11,4 +11,17 @@ namespace :search_results do
11 11
       end
12 12
     end
13 13
   end
  14
+
  15
+  desc "Recalculate votes count"
  16
+  task :recalculate_votes_count => :environment do
  17
+    SearchResult.find_each(:batch_size => 10_000) do |sr|
  18
+      votes_count = sr.votes.count
  19
+      if votes_count != sr.votes_count
  20
+        sr.set(:votes_count => votes_count)
  21
+        print 'C'
  22
+      else
  23
+        print '.'
  24
+      end
  25
+    end
  26
+  end
14 27
 end

0 notes on commit d66d1bd

Please sign in to comment.
Something went wrong with that request. Please try again.