#336: use set instead of list
This commit is contained in:
parent
df83fe65e1
commit
6a6fcc321f
|
@ -11,7 +11,7 @@ var _locales = {
|
|||
'Всего %1 тега',
|
||||
'Всего %1 тегов'
|
||||
],
|
||||
<%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}':'#{BuildList.human_status(s)}'"}.join(',') %>
|
||||
<%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>
|
||||
},
|
||||
<%I18n.locale = :en%>
|
||||
'en-us': {
|
||||
|
@ -23,6 +23,6 @@ var _locales = {
|
|||
'Total %1 tag',
|
||||
'Total %1 tags'
|
||||
],
|
||||
<%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}':'#{BuildList.human_status(s)}'"}.join(',') %>
|
||||
<%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>
|
||||
}
|
||||
};
|
|
@ -146,19 +146,16 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
after_transition do |build_list, transition|
|
||||
status = HUMAN_STATUSES[build_list.status]
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
end
|
||||
|
||||
after_transition :on => :place_build, :do => :add_job_to_abf_worker_queue,
|
||||
:if => lambda { |build_list| build_list.external_nodes.blank? }
|
||||
after_transition :on => :published,
|
||||
:do => [:set_version_and_tag, :actualize_packages]
|
||||
after_transition :on => :publish, :do => :set_publisher
|
||||
after_transition :build_published_into_testing => :publish, :do => :cleanup_packages_from_testing
|
||||
after_transition(:on => :publish) do |build_list, transition|
|
||||
if transition.from == BUILD_PUBLISHED_INTO_TESTING
|
||||
build_list.cleanup_packages_from_testing
|
||||
end
|
||||
end
|
||||
after_transition :on => :cancel, :do => :cancel_job
|
||||
|
||||
after_transition :on => [:published, :fail_publish, :build_error, :tests_failed], :do => :notify_users
|
||||
|
@ -489,6 +486,14 @@ class BuildList < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
def cleanup_packages_from_testing
|
||||
AbfWorker::BuildListsPublishTaskManager.cleanup_packages_from_testing(
|
||||
build_for_platform_id,
|
||||
save_to_repository_id,
|
||||
id
|
||||
)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def create_container
|
||||
|
@ -541,14 +546,6 @@ class BuildList < ActiveRecord::Base
|
|||
save
|
||||
end
|
||||
|
||||
def cleanup_packages_from_testing
|
||||
AbfWorker::BuildListsPublishTaskManager.cleanup_packages_from_testing(
|
||||
build_for_platform_id,
|
||||
save_to_repository_id,
|
||||
id
|
||||
)
|
||||
end
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(user)
|
||||
end
|
||||
|
|
|
@ -62,9 +62,10 @@ module AbfWorker
|
|||
|
||||
def cleanup_packages_from_testing(platform_id, repository_id, *build_lists)
|
||||
return if build_lists.blank?
|
||||
key = "#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{repository_id}-#{platform_id}"
|
||||
redis.lpush REP_AND_PLS_OF_BUILD_LISTS_FOR_CLEANUP_FROM_TESTING, "#{repository_id}-#{platform_id}"
|
||||
redis.lpush key, build_lists
|
||||
rep_pl = "#{repository_id}-#{platform_id}"
|
||||
key = "#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{rep_pl}"
|
||||
redis.sadd REP_AND_PLS_OF_BUILD_LISTS_FOR_CLEANUP_FROM_TESTING, "#{rep_pl}"
|
||||
redis.sadd key, build_lists
|
||||
end
|
||||
|
||||
def unlock_build_list(build_list)
|
||||
|
@ -222,8 +223,8 @@ module AbfWorker
|
|||
locked_rep.present? && locked_rep.include?(rep.to_i) ? nil : [rep.to_i, pl.to_i]
|
||||
end.compact
|
||||
|
||||
for_cleanup_from_testing = @redis.lrange(REP_AND_PLS_OF_BUILD_LISTS_FOR_CLEANUP_FROM_TESTING, 0, -1).map do |key|
|
||||
next if redis.llen("#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{key}") == 0
|
||||
for_cleanup_from_testing = @redis.smembers(REP_AND_PLS_OF_BUILD_LISTS_FOR_CLEANUP_FROM_TESTING).map do |key|
|
||||
next if @redis.scard("#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{key}") == 0
|
||||
rep, pl = *key.split('-')
|
||||
locked_rep.present? && locked_rep.include?(rep.to_i) ? nil : [rep.to_i, pl.to_i]
|
||||
end.compact if testing
|
||||
|
@ -270,24 +271,20 @@ module AbfWorker
|
|||
packages = JSON.parse packages
|
||||
old_packages[:sources] |= packages['sources']
|
||||
Arch.pluck(:name).each do |arch|
|
||||
old_packages[:binaries][arch.to_sym] |= packages['binaries'][arch]
|
||||
old_packages[:binaries][arch.to_sym] |= packages['binaries'][arch] || []
|
||||
end
|
||||
end
|
||||
|
||||
if testing
|
||||
build_lists_for_cleanup_from_testing = @redis.lrange(
|
||||
"#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{save_to_repository_id}-#{build_for_platform_id}"
|
||||
0, -1
|
||||
)
|
||||
build_lists_for_cleanup_from_testing = @redis.smembers("#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{save_to_repository_id}-#{build_for_platform_id}")
|
||||
BuildList.where(:id => build_lists_for_cleanup_from_testing).each do |b|
|
||||
self.class.fill_packages(b, old_packages)
|
||||
end if build_lists_for_cleanup_from_testing.present?
|
||||
end
|
||||
build_lists_for_cleanup_from_testing ||= []
|
||||
|
||||
|
||||
bl = build_lists.first
|
||||
return false if !bl && old_packages[:sources].empty?
|
||||
return false if !bl && old_packages[:binaries].values.flatten.empty?
|
||||
|
||||
save_to_repository = Repository.find save_to_repository_id
|
||||
# Checks mirror sync status
|
||||
|
@ -369,7 +366,7 @@ module AbfWorker
|
|||
end
|
||||
|
||||
build_lists_for_cleanup_from_testing.each do |key|
|
||||
@redis.lrem "#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{save_to_repository_id}-#{build_for_platform_id}", 0, key
|
||||
@redis.srem "#{BUILD_LISTS_FOR_CLEANUP_FROM_TESTING}-#{save_to_repository_id}-#{build_for_platform_id}", key
|
||||
end
|
||||
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue