Commit a94eb160cfef9dc1e2f2e9976b6cf6580929ef95

Authored by Antonio Terceiro
1 parent 045a4ac4

[spaminator] better progress indication

plugins/anti_spam/lib/anti_spam_plugin/spaminator.rb
@@ -47,8 +47,10 @@ class AntiSpamPlugin::Spaminator @@ -47,8 +47,10 @@ class AntiSpamPlugin::Spaminator
47 def process_all_comments 47 def process_all_comments
48 puts 'Processing comments ...' 48 puts 'Processing comments ...'
49 i = 0 49 i = 0
50 - Comment.joins("JOIN articles ON (comments.source_id = articles.id AND comments.source_type = 'Article') JOIN profiles ON (profiles.id = articles.profile_id)").where(conditions(:comments)).find_each do |comment|  
51 - puts "Comment #{i += 1}" 50 + comments = Comment.joins("JOIN articles ON (comments.source_id = articles.id AND comments.source_type = 'Article') JOIN profiles ON (profiles.id = articles.profile_id)").where(conditions(:comments))
  51 + total = comments.count
  52 + comments.find_each do |comment|
  53 + puts "Comment #{i += 1}/#{total} (#{100*i/total}%)"
52 process_comment(comment) 54 process_comment(comment)
53 end 55 end
54 end 56 end
@@ -56,8 +58,10 @@ class AntiSpamPlugin::Spaminator @@ -56,8 +58,10 @@ class AntiSpamPlugin::Spaminator
56 def process_all_people 58 def process_all_people
57 puts 'Processing people ...' 59 puts 'Processing people ...'
58 i = 0 60 i = 0
59 - Person.where(conditions(:profiles)).find_each do |person|  
60 - puts "Person #{i += 1}" 61 + people = Person.where(conditions(:profiles))
  62 + total = people.count
  63 + people.find_each do |person|
  64 + puts "Person #{i += 1}/#{total} (#{100*i/total}%)"
61 process_person(person) 65 process_person(person)
62 end 66 end
63 end 67 end