Commit a94eb160cfef9dc1e2f2e9976b6cf6580929ef95
1 parent
045a4ac4
Exists in
master
and in
28 other branches
[spaminator] better progress indication
Showing
1 changed file
with
8 additions
and
4 deletions
Show diff stats
plugins/anti_spam/lib/anti_spam_plugin/spaminator.rb
| ... | ... | @@ -47,8 +47,10 @@ class AntiSpamPlugin::Spaminator |
| 47 | 47 | def process_all_comments |
| 48 | 48 | puts 'Processing comments ...' |
| 49 | 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 | 54 | process_comment(comment) |
| 53 | 55 | end |
| 54 | 56 | end |
| ... | ... | @@ -56,8 +58,10 @@ class AntiSpamPlugin::Spaminator |
| 56 | 58 | def process_all_people |
| 57 | 59 | puts 'Processing people ...' |
| 58 | 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 | 65 | process_person(person) |
| 62 | 66 | end |
| 63 | 67 | end | ... | ... |