diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index 9aaf91e..58d4b3a 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -1,14 +1,16 @@ namespace :cleanup do desc "Cleanup completed jobs" task :jobs => :environment do count = Job.completed.count - WebDNS.settings[:completed_jobs_count] count = count < 0 ? 0 : count + puts "Will remove %s jobs" % count Job.completed.order(created_at: :desc).limit(count).destroy_all + puts "Done" end # add new jobs here too task :all => [:jobs] end desc "Cleanup everything" task :cleanup => 'cleanup:all'