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