Sha256: f14fb5e728a158a6cf63e7afba1cfe49fc40fc12cb0348a2ef17736193256956

Contents?: true

Size: 1.18 KB

Versions: 34

Compression:

Stored size: 1.18 KB

Contents

module Actions
  module Katello
    module OrphanCleanup
      class RemoveOrphans < Pulp::Abstract
        input_format do
          param :capsule_id
        end
        def plan(proxy)
          sequence do
            plan_action(Actions::Pulp::Orchestration::OrphanCleanup::RemoveOrphans, proxy)
            if proxy.pulp3_enabled?
              plan_action(
                Actions::Pulp3::Orchestration::OrphanCleanup::RemoveOrphans,
                proxy)
            end
            plan_self
          end
        end

        def run
          models = []
          ::Katello::RepositoryTypeManager.repository_types.each_value do |repo_type|
            indexable_types = repo_type.content_types_to_index
            models += indexable_types&.map(&:model_class)
            models.select! { |model| model.many_repository_associations }
          end
          models.each do |model|
            model.joins("left join katello_#{model.repository_association} on #{model.table_name}.id = katello_#{model.repository_association}.#{model.unit_id_field}").where("katello_#{model.repository_association}.#{model.unit_id_field} IS NULL").destroy_all
          end
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
katello-4.0.1.2 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.1.0.rc2.2 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.1.0.rc2.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.1.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.1.0.rc2 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.1.0.rc1.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.1.0.rc1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.0 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.0.rc3.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.0.rc3 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.18.2.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.18.2 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.17.3 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.0.rc2 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.18.1.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.17.2 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-4.0.0.rc1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.18.1 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
katello-3.18.0 app/lib/actions/katello/orphan_cleanup/remove_orphans.rb