#463: Increased life time for builds of mass builds
This commit is contained in:
parent
ba84f0f916
commit
e599be5828
|
@ -154,9 +154,16 @@ class BuildList < ActiveRecord::Base
|
|||
joins(:project).where('projects.name LIKE ?', "%#{project_name}%") if project_name.present?
|
||||
}
|
||||
scope :scoped_to_new_core, ->(new_core) { where(new_core: new_core) }
|
||||
scope :outdated, -> {
|
||||
where("#{table_name}.created_at < ? AND #{table_name}.status NOT IN (?) OR #{table_name}.created_at < ?",
|
||||
Time.now - LIVE_TIME, [BUILD_PUBLISHED,BUILD_PUBLISHED_INTO_TESTING], Time.now - MAX_LIVE_TIME)
|
||||
scope :outdated, -> (now = Time.now) {
|
||||
where(<<-SQL, now - LIVE_TIME, [BUILD_PUBLISHED,BUILD_PUBLISHED_INTO_TESTING], now - MAX_LIVE_TIME)
|
||||
(
|
||||
#{table_name}.created_at < ? AND
|
||||
#{table_name}.status NOT IN (?) AND
|
||||
#{table_name}.mass_build_id IS NULL
|
||||
) OR (
|
||||
#{table_name}.created_at < ?
|
||||
)
|
||||
SQL
|
||||
}
|
||||
scope :published_container, -> { where(container_status: BUILD_PUBLISHED) }
|
||||
|
||||
|
|
|
@ -7,17 +7,15 @@ namespace :buildlist do
|
|||
say "[#{Time.zone.now}] Removing outdated BuildLists"
|
||||
say "[#{Time.zone.now}] There are #{BuildList.outdated.count} outdated BuildLists"
|
||||
counter = 0
|
||||
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
|
||||
BuildList.outdated.find_each(batch_size: 100) do |bl|
|
||||
bl.destroy && (counter += 1) if bl.id != bl.last_published.first.try(:id)
|
||||
end
|
||||
say "[#{Time.zone.now}] #{counter} outdated BuildLists have been removed"
|
||||
|
||||
say "[#{Time.zone.now}] Removing outdated MassBuilds"
|
||||
say "[#{Time.zone.now}] There are #{MassBuild.outdated.count} outdated MassBuilds"
|
||||
counter = 0
|
||||
MassBuild.outdated.each do |mb|
|
||||
MassBuild.outdated.find_each do |mb|
|
||||
mb.destroy && (counter += 1) if mb.build_lists.count == 0
|
||||
end
|
||||
say "[#{Time.zone.now}] #{counter} outdated MassBuilds have been removed"
|
||||
|
@ -36,7 +34,7 @@ namespace :buildlist do
|
|||
|
||||
counter = 0
|
||||
scope.find_each do |bl|
|
||||
bl.destroy && (counter += 1)
|
||||
bl.destroy && (counter += 1)
|
||||
end
|
||||
|
||||
say "[#{Time.zone.now}] #{counter} outdated BuildLists have been removed"
|
||||
|
|
Loading…
Reference in New Issue