#25: Save last publishing build list regardless of their age

This commit is contained in:
Vokhmin Alexey V 2013-03-15 18:40:39 +04:00
parent b8a02299fd
commit 0aeaec11b2
1 changed files with 17 additions and 9 deletions

View File

@ -4,17 +4,25 @@ namespace :buildlist do
namespace :clear do namespace :clear do
desc 'Remove outdated BuildLists and MassBuilds' desc 'Remove outdated BuildLists and MassBuilds'
task :outdated => :environment do task :outdated => :environment do
say "Removing outdated BuildLists" say "[#{Time.zone.now}] Removing outdated BuildLists"
outdated = BuildList.outdated say "[#{Time.zone.now}] There are #{BuildList.outdated.count} outdated BuildLists"
say "There are #{outdated.count} outdated BuildLists at #{Time.now}" counter = 0
BuildList.outdated.destroy_all BuildList.outdated.order(:id).find_in_batches(:batch_size => 100) do |build_lists|
build_lists.each do |bl|
bl.destroy && (counter += 1) if bl.id != bl.last_published.first.try(:id)
end
end
say "[#{Time.zone.now}] #{counter} outdated BuildLists have been removed"
say "Removing outdated MassBuilds" say "[#{Time.zone.now}] Removing outdated MassBuilds"
outdated = MassBuild.outdated say "[#{Time.zone.now}] There are #{MassBuild.outdated.count} outdated MassBuilds"
say "There are #{outdated.count} outdated MassBuilds at #{Time.now}" counter = 0
MassBuild.outdated.destroy_all MassBuild.outdated.each do |mb|
mb.destroy && (counter += 1) if mb.build_lists.count == 0
end
say "[#{Time.zone.now}] #{counter} outdated MassBuilds have been removed"
say "Outdated BuildLists and MassBuilds was successfully removed" say "[#{Time.zone.now}] Outdated BuildLists and MassBuilds was successfully removed"
end end
end end