From 2de847a59016864e538eb9af086753118f3be584 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Thu, 14 Sep 2023 20:04:46 +0000 Subject: [PATCH] Fixes #36750 - Add aggregated CV version content counts to count field and return via API --- app/models/katello/concerns/smart_proxy_extensions.rb | 11 ++++++++++- .../api/v2/capsule_content/sync_status.json.rabl | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/katello/concerns/smart_proxy_extensions.rb b/app/models/katello/concerns/smart_proxy_extensions.rb index 9261e647b0d..4a1bb9de83b 100644 --- a/app/models/katello/concerns/smart_proxy_extensions.rb +++ b/app/models/katello/concerns/smart_proxy_extensions.rb @@ -131,6 +131,7 @@ def update_content_counts! repos.each do |repo| repo_mirror_service = repo.backend_service(self).with_mirror_adapter repo_content_counts = repo_mirror_service.latest_content_counts + total_count = {} translated_counts = {} repo_content_counts.each do |name, count| count = count[:count] @@ -145,8 +146,16 @@ def update_content_counts! translated_counts[::Katello::Pulp3::PulpContentUnit.katello_name_from_pulpcore_name(name, repo)] = count end end - new_content_counts[:content_view_versions][repo.content_view_version_id] ||= { repositories: {} } + new_content_counts[:content_view_versions][repo.content_view_version_id] ||= { repositories: {}, cv_version_content_counts: {}} new_content_counts[:content_view_versions][repo.content_view_version_id][:repositories][repo.id] = translated_counts + translated_counts.keys.each do |content_type| + new_content_counts[:content_view_versions][repo.content_view_version_id][:cv_version_content_counts][content_type] = + if new_content_counts[:content_view_versions][repo.content_view_version_id][:cv_version_content_counts][content_type] + new_content_counts[:content_view_versions][repo.content_view_version_id][:cv_version_content_counts][content_type] + translated_counts[content_type] + else + translated_counts[content_type] + end + end end update(content_counts: new_content_counts) end diff --git a/app/views/katello/api/v2/capsule_content/sync_status.json.rabl b/app/views/katello/api/v2/capsule_content/sync_status.json.rabl index 6b0904dcd6f..e499e14b328 100644 --- a/app/views/katello/api/v2/capsule_content/sync_status.json.rabl +++ b/app/views/katello/api/v2/capsule_content/sync_status.json.rabl @@ -43,7 +43,8 @@ child @lifecycle_environments => :lifecycle_environments do :up_to_date => @capsule.repos_pending_sync(env, content_view).empty?, :counts => { :repositories => ::Katello::ContentViewVersion.in_environment(env).find_by(:content_view => content_view)&.archived_repos&.count - } + }, + :content_counts => @capsule.content_counts } attributes end