rosa-build/app/jobs/run_extra_mass_builds_job.rb

27 lines
780 B
Ruby
Raw Permalink Normal View History

2016-05-28 19:21:02 +01:00
class RunExtraMassBuildsJob < BaseActiveRecordJob
include Sidekiq::Worker
sidekiq_options :queue => :low
2014-07-09 21:24:41 +01:00
2016-05-28 19:21:02 +01:00
def perform_with_ar_connection
2014-07-09 21:31:32 +01:00
MassBuild.where(status: MassBuild::BUILD_PENDING).find_each do |mb|
2014-07-09 21:24:41 +01:00
next if mb.extra_mass_builds.blank?
2014-07-09 21:31:32 +01:00
emb = MassBuild.where(status: MassBuild::SUCCESS, id: mb.extra_mass_builds).to_a
2014-07-09 21:24:41 +01:00
next if emb.size != mb.extra_mass_builds.size
next if emb.find{ |mb| not_ready?(mb) }
mb.build_all
end
end
private
# Returns true if mass build has not published packages or packages without container
def not_ready?(mb)
mb.build_lists.count != mb.build_lists.where(
'status = ? OR container_status = ?',
BuildList::BUILD_PUBLISHED,
BuildList::BUILD_PUBLISHED
).count
end
end