Skip to content

Commit

Permalink
Fixes #34609 - Entitlement report double counts consumed entitlements (
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Mar 17, 2022
1 parent 504111f commit cf82cbb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/katello/concerns/host_managed_extensions.rb
Expand Up @@ -424,6 +424,12 @@ def advisory_ids(search:)
::Katello::Erratum.installable_for_hosts([self]).search_for(search).pluck(:errata_id)
end

def filtered_entitlement_quantity_consumed(pool)
entitlements = subscription_facet.candlepin_consumer.filter_entitlements(pool.cp_id)
return nil if entitlements.empty?
entitlements.sum { |e| e[:quantity] }
end

protected

def update_trace_status
Expand All @@ -441,7 +447,8 @@ def enabled_module_stream_inactive?(module_stream)
class ::Host::Managed::Jail < Safemode::Jail
allow :content_source, :subscription_manager_configuration_url, :rhsm_organization_label,
:host_collections, :pools, :hypervisor_host, :lifecycle_environment, :content_view,
:installed_packages, :traces_helpers, :advisory_ids, :package_names_for_job_template
:installed_packages, :traces_helpers, :advisory_ids, :package_names_for_job_template,
:filtered_entitlement_quantity_consumed
end

class ActiveRecord::Associations::CollectionProxy::Jail < Safemode::Jail
Expand Down

0 comments on commit cf82cbb

Please sign in to comment.