Commit 7db8da2a68bf295bad3ec123a9d92f53ea03d49f
Exists in
master
and in
1 other branch
Merge branch 'master' of https://github.com/cr0t/errbit into cr0t-master
Conflicts: lib/tasks/errbit/database.rake
Showing
1 changed file
with
17 additions
and
0 deletions
Show diff stats
lib/tasks/errbit/database.rake
@@ -53,5 +53,22 @@ namespace :errbit do | @@ -53,5 +53,22 @@ namespace :errbit do | ||
53 | end | 53 | end |
54 | end | 54 | end |
55 | 55 | ||
56 | + desc "Remove notices in batch" | ||
57 | + task :notices_delete, [ :problem_id ] => [ :environment ] do | ||
58 | + BATCH_SIZE = 1000 | ||
59 | + if args[:problem_id] | ||
60 | + item_count = Problem.find(args[:problem_id]).notices.count | ||
61 | + removed_count = 0 | ||
62 | + puts "Notices to remove: #{item_count}" | ||
63 | + while item_count > 0 | ||
64 | + Problem.find(args[:problem_id]).notices.limit(BATCH_SIZE).each do |notice| | ||
65 | + notice.remove | ||
66 | + removed_count += 1 | ||
67 | + end | ||
68 | + item_count -= BATCH_SIZE | ||
69 | + puts "Removed #{removed_count} notices" | ||
70 | + end | ||
71 | + end | ||
72 | + end | ||
56 | end | 73 | end |
57 | end | 74 | end |