2016-03-22 17:02:49 +00:00
|
|
|
class RemoveOutdatedItemsJob
|
|
|
|
@queue = :low
|
|
|
|
|
|
|
|
def self.perform
|
|
|
|
log_file = Rails.root.join("log", "remove_outdated.log").to_s
|
|
|
|
counter_bl = 0
|
|
|
|
BuildList.outdated.find_each(batch_size: 100) do |bl|
|
|
|
|
bl.destroy && (counter_bl += 1) if bl.id != bl.last_published.first.try(:id)
|
|
|
|
end
|
|
|
|
counter_mb = 0
|
|
|
|
MassBuild.outdated.find_each do |mb|
|
|
|
|
mb.destroy && (counter_mb += 1) if mb.build_lists.count == 0
|
|
|
|
end
|
|
|
|
counter_pbl = ProductBuildList.outdated.count
|
|
|
|
ProductBuildList.outdated.destroy_all
|
2016-05-03 19:04:24 +01:00
|
|
|
User.find_each(batch_size: 50) do |u|
|
|
|
|
u.activity_feeds.outdated.destroy_all
|
|
|
|
end
|
2016-03-22 17:02:49 +00:00
|
|
|
File.open(log_file, "w") do |f|
|
|
|
|
f.puts "Build Lists deleted: #{counter_bl}"
|
|
|
|
f.puts "Mass Builds deleted: #{counter_mb}"
|
|
|
|
f.puts "Product Build Lists deleted: #{counter_pbl}"
|
|
|
|
end
|
|
|
|
end
|
2016-05-03 19:04:24 +01:00
|
|
|
end
|