From 6958c463c61128857020952120e6d25d718efb22 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 31 Jan 2014 21:12:24 +0400 Subject: [PATCH] Cleanup build_lists with status canceling --- config/schedule.rb | 18 +++++++++++------- lib/tasks/buildlist.rake | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index 508f63318..977e36e1b 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,29 +1,29 @@ #every 1.day, at: '0:05 am' do -# runner "Download.rotate_nginx_log" +# runner 'Download.rotate_nginx_log' #end # #every 1.day, at: '0:10 am' do -# runner "Download.parse_and_remove_nginx_log" +# runner 'Download.parse_and_remove_nginx_log' #end every :day, at: '4:10 am' do - rake "product_build_list:clear:outdated", output: 'log/product_build_list_clear.log' + rake 'product_build_list:clear:outdated', output: 'log/product_build_list_clear.log' end every :day, at: '4:00 am' do - rake "import:sync:all", output: 'log/sync.log' + rake 'import:sync:all', output: 'log/sync.log' end every :day, at: '3:50 am' do - rake "buildlist:clear:outdated", output: 'log/build_list_clear.log' + rake 'buildlist:clear:outdated', output: 'log/build_list_clear.log' end every :day, at: '3:30 am' do - rake "pull_requests:clear", output: 'log/pull_requests_clear.log' + rake 'pull_requests:clear', output: 'log/pull_requests_clear.log' end every :day, at: '3:00 am' do - rake "activity_feeds:clear", output: 'log/activity_feeds.log' + rake 'activity_feeds:clear', output: 'log/activity_feeds.log' end every 3.minute do @@ -34,6 +34,10 @@ every 1.minute do runner 'RpmBuildNode.cleanup!' end +every 1.hour do + rake 'buildlist:clear:outdated_canceling', output: 'log/canceling_build_list_clear.log' +end + every :day, at: '4am' do runner 'Product.autostart_iso_builds_once_a_12_hours', output: 'log/autostart_iso_builds.log' runner 'Product.autostart_iso_builds_once_a_day', output: 'log/autostart_iso_builds.log' diff --git a/lib/tasks/buildlist.rake b/lib/tasks/buildlist.rake index b97983786..b03678cb5 100644 --- a/lib/tasks/buildlist.rake +++ b/lib/tasks/buildlist.rake @@ -24,6 +24,25 @@ namespace :buildlist do say "[#{Time.zone.now}] Outdated BuildLists and MassBuilds was successfully removed" end + + desc 'Remove outdated BuildLists with status BUILD_CANCELING' + task outdated_canceling: :environment do + say "[#{Time.zone.now}] Removing outdated BuildLists" + + scope = BuildList.for_status(BuildList::BUILD_CANCELING). + for_notified_date_period(nil, Time.zone.now - 3.hours) + + say "[#{Time.zone.now}] There are #{scope.count} outdated BuildLists" + + counter = 0 + scope.find_each do |bl| + bl.destroy && (counter += 1) + end + + say "[#{Time.zone.now}] #{counter} outdated BuildLists have been removed" + say "[#{Time.zone.now}] Outdated BuildLists were successfully removed" + end + end namespace :packages do