Add rake task to clean DB

This commit is contained in:
Dzmitry Plashchynski
2015-03-16 17:34:25 +02:00
parent f57d440424
commit 7328bea24c
6 changed files with 25 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
namespace :crono do
desc 'Clean unused job stats from DB'
task clean: :environment do
Crono.scheduler = Crono::Scheduler.new
require File.join(Rails.root, 'config', 'cronotab')
current_job_ids = Crono.scheduler.jobs.map(&:job_id)
Crono::CronoJob.where.not(job_id: current_job_ids).destroy_all
end
end