Sha256: 3c5b19b933ea5f1d03e6fcf081df53a933179537106272ad800a1f0171cc2b84

Contents?: true

Size: 842 Bytes

Versions: 16

Compression:

Stored size: 842 Bytes

Contents

module Katello
  class HostPackagePresenter < SimpleDelegator
    attr_accessor :installed_package, :upgradable_versions, :rpm_id

    def initialize(installed_package, upgradable_versions, rpm_id)
      @installed_package = installed_package
      @upgradable_versions = upgradable_versions
      @rpm_id = rpm_id
      super(@installed_package)
    end

    def self.with_latest(packages, host)
      upgradable_packages_map = ::Katello::Rpm.installable_for_hosts([host]).select(:id, :name, :nvra, :evr).order(evr: :desc).all.group_by(&:name)
      installed_packages_map = ::Katello::Rpm.where(nvra: packages.map(&:nvra)).select(:id, :name).group_by(&:name)

      packages.map do |p|
        HostPackagePresenter.new(p, upgradable_packages_map[p.name]&.pluck(:nvra), installed_packages_map[p.name]&.first&.id)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
katello-4.8.4 app/presenters/katello/host_package_presenter.rb
katello-4.8.3 app/presenters/katello/host_package_presenter.rb
katello-4.7.6 app/presenters/katello/host_package_presenter.rb
katello-4.8.2 app/presenters/katello/host_package_presenter.rb
katello-4.8.1 app/presenters/katello/host_package_presenter.rb
katello-4.7.5 app/presenters/katello/host_package_presenter.rb
katello-4.8.0 app/presenters/katello/host_package_presenter.rb
katello-4.8.0.rc2 app/presenters/katello/host_package_presenter.rb
katello-4.7.4 app/presenters/katello/host_package_presenter.rb
katello-4.8.0.rc1 app/presenters/katello/host_package_presenter.rb
katello-4.7.3 app/presenters/katello/host_package_presenter.rb
katello-4.7.2 app/presenters/katello/host_package_presenter.rb
katello-4.7.1 app/presenters/katello/host_package_presenter.rb
katello-4.7.0 app/presenters/katello/host_package_presenter.rb
katello-4.7.0.rc2 app/presenters/katello/host_package_presenter.rb
katello-4.7.0.rc1 app/presenters/katello/host_package_presenter.rb