Sha256: 5b74ab457350634b9d6eceedf75eab4aef9f79349ca6ff9ac6d197ed6763b528

Contents?: true

Size: 618 Bytes

Versions: 102

Compression:

Stored size: 618 Bytes

Contents

module Katello
  class HostSubscriptionsPresenter
    attr_reader :subscriptions

    def initialize(host)
      pools = host.subscription_facet&.pools || []
      @pools = pools.group_by(&:cp_id)

      entitlements = host.subscription_facet.candlepin_consumer.entitlements if @pools.any?
      entitlements ||= []

      @subscriptions = entitlements.map do |e|
        HostSubscriptionPresenter.new(pool: pool_for_entitlement(e), entitlement: e)
      end
    end

    private

    def pool_for_entitlement(entitlement)
      pool_cp_id = entitlement['pool']['id']
      @pools[pool_cp_id]&.first
    end
  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
katello-4.14.3 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.2 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.15.0 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.15.0.rc2 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.15.0.rc1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.0 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.0.rc3 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.0.rc2 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.0.rc1.1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.14.0.rc1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.13.1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.13.0 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.12.1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.13.0.rc1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.12.0 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.12.0.rc3 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.12.0.rc2 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.12.0.rc1 app/presenters/katello/host_subscriptions_presenter.rb
katello-4.11.1 app/presenters/katello/host_subscriptions_presenter.rb