Skip to content

Commit

Permalink
Fixes #38003 - more efficient handle_acs_product_removal
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Moravec <[email protected]>
  • Loading branch information
pmoravec committed Nov 15, 2024
1 parent c08f449 commit 7ad9723
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions app/lib/actions/katello/repository/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ def handle_acs_product_removal(repository)
# Remove products from ACS's that contain no repositories which both
# match the ACS content type and have a non-nil URL
product = repository.product
repo_content_types = Set.new
product.repositories.each do |test_repo|
# we need to check id because test_repo will still contain the old, non-nil url
repo_content_types.add(test_repo.content_type) if (repository.id != test_repo.id) && test_repo.url.present?
end
repo_content_types = ::Katello::RootRepository.where(:id => product.repositories.where.not(:id => repository.id).select(:root_id)).where.not(:url => [nil, '']).distinct.pluck(:content_type)
::Katello::AlternateContentSource.with_products(product).each do |acs|
unless repo_content_types.include?(acs.content_type)
acs.products = acs.products - [product]
Expand Down
6 changes: 1 addition & 5 deletions app/lib/actions/katello/repository/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ def handle_acs_product_removal(repository)
# Remove products from ACS's that contain no repositories which both
# match the ACS content type and have a non-nil URL
product = repository.product
repo_content_types = Set.new
product.acs_compatible_repositories.each do |test_repo|
# we need to check id because test_repo will still contain the old, non-nil url
repo_content_types.add(test_repo.content_type) if (repository.id != test_repo.id) && test_repo.url.present?
end
repo_content_types = ::Katello::RootRepository.where(:id => product.repositories.where.not(:id => repository.id).select(:root_id)).where.not(:url => [nil, '']).distinct.pluck(:content_type)
::Katello::AlternateContentSource.with_products(product).each do |acs|
unless repo_content_types.include?(acs.content_type)
acs.products = acs.products - [product]
Expand Down

0 comments on commit 7ad9723

Please sign in to comment.