Sha256: 045e052de2047248a821f2729ccbc511e16f072d4af3754e92dda6114a24bb14

Contents?: true

Size: 793 Bytes

Versions: 64

Compression:

Stored size: 793 Bytes

Contents

module Actions
  module Pulp
    module Repository
      class PurgeEmptyPackageGroups < Pulp::AbstractAsyncTask
        input_format do
          param :pulp_id, Integer
        end

        def invoke_external_task
          repo = ::Katello::Repository.where(:pulp_id => input[:pulp_id]).first
          rpm_names = repo.rpms.pluck(:name).uniq

          # Remove all  package groups with no packages
          package_groups_to_delete = repo.package_groups.select do |group|
            (rpm_names & group.package_names).empty?
          end
          criteria = {:association => {"unit_id" => {"$in" => package_groups_to_delete.compact}}}

          ::Katello.pulp_server.extensions.repository.unassociate_units(repo.pulp_id, :filters => criteria)
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
katello-3.0.1 app/lib/actions/pulp/repository/purge_empty_package_groups.rb
katello-3.0.0 app/lib/actions/pulp/repository/purge_empty_package_groups.rb
katello-3.0.0.rc7 app/lib/actions/pulp/repository/purge_empty_package_groups.rb
katello-3.0.0.rc5 app/lib/actions/pulp/repository/purge_empty_package_groups.rb