#298: added checking of new packages on publishing of mass_build

This commit is contained in:
Vokhmin Alexey V 2013-09-10 17:58:58 +04:00
parent 645a1b5181
commit 5db6be8d87
2 changed files with 6 additions and 4 deletions

View File

@ -280,9 +280,7 @@ class BuildList < ActiveRecord::Base
build_started? || build_pending? build_started? || build_pending?
end end
def can_auto_publish? def has_new_packages?
return false if !(auto_publish? && can_publish?)
if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last
source_packages.each do |nsp| source_packages.each do |nsp|
sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name } sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name }
@ -298,6 +296,10 @@ class BuildList < ActiveRecord::Base
return false # no new packages return false # no new packages
end end
def can_auto_publish?
auto_publish? && can_publish? && has_new_packages?
end
def can_publish? def can_publish?
[SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(:id => project_id) [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(:id => project_id)
end end

View File

@ -99,7 +99,7 @@ class MassBuild < ActiveRecord::Base
builds = build_lists.where(:status => statuses) builds = build_lists.where(:status => statuses)
builds.update_all(:publisher_id => user.id) builds.update_all(:publisher_id => user.id)
builds.order(:id).find_in_batches(:batch_size => 50) do |bls| builds.order(:id).find_in_batches(:batch_size => 50) do |bls|
bls.each{ |bl| bl.can_publish? && bl.now_publish } bls.each{ |bl| bl.can_publish? && bl.has_new_packages? && bl.now_publish }
end end
end end