Commit b0cc2ccc47bcd36df392f3efadbd77200bbb180a

Authored by Nathan Broadbent
1 parent 3a8a114a
Exists in master and in 1 other branch production

Added rake task to clear all resolved errors from database. Also grouped db task…

…s together in tasks/database.rake [ci skip]
lib/tasks/errbit/database.rake 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +namespace :errbit do
  2 + namespace :db do
  3 + desc "Updates Err#notices_count"
  4 + task :update_err_message => :environment do
  5 + puts "Updating err.message"
  6 + Err.all.each do |e|
  7 + e.update_attributes(:message => e.notices.first.message) if e.notices.first
  8 + end
  9 + end
  10 +
  11 + desc "Updates Err#notices_count"
  12 + task :update_notices_count => :environment do
  13 + puts "Updating err.notices_count"
  14 + Err.all.each do |e|
  15 + e.update_attributes(:notices_count => e.notices.count)
  16 + end
  17 + end
  18 +
  19 + desc "Delete resolved errors from the database. (Useful for limited heroku databases)"
  20 + task :clear_resolved => :environment do
  21 + count = Err.resolved.count
  22 + Err.resolved.each {|err| err.destroy }
  23 + puts "=== Cleared #{count} resolved errors from the database." if count > 0
  24 + end
  25 + end
  26 +end
  27 +
... ...
lib/tasks/errbit/err_message.rake
... ... @@ -1,12 +0,0 @@
1   -namespace :errbit do
2   -
3   - namespace :db do
4   - desc "Updates Err#notices_count"
5   - task :update_err_message => :environment do
6   - puts "Updating err.message"
7   - Err.all.each do |e|
8   - e.update_attributes(:message => e.notices.first.message) if e.notices.first
9   - end
10   - end
11   - end
12   -end
lib/tasks/errbit/notices_counter.rake
... ... @@ -1,12 +0,0 @@
1   -namespace :errbit do
2   -
3   - namespace :db do
4   - desc "Updates Err#notices_count"
5   - task :update_notices_count => :environment do
6   - puts "Updating err.notices_count"
7   - Err.all.each do |e|
8   - e.update_attributes(:notices_count => e.notices.count)
9   - end
10   - end
11   - end
12   -end