2014-07-09 21:24:41 +01:00
|
|
|
class RunExtraMassBuildsJob
|
|
|
|
@queue = :low
|
|
|
|
|
|
|
|
def self.perform
|
|
|
|
RunExtraMassBuildsJob.new.perform
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
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
|