Skip to content

Commit

Permalink
Fixes #36750 - Add aggregated CV version content counts to count fiel…
Browse files Browse the repository at this point in the history
…d and return via API
  • Loading branch information
sjha4 committed Sep 14, 2023
1 parent d16c8b1 commit 4d47028
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,33 @@ 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]
# Some content units in Pulp have the same model
if name == 'rpm.package' && repo.content_counts['srpm'] > 0
translated_counts['srpm'] = repo_mirror_service.count_by_pulpcore_type(::Katello::Pulp3::Srpm)
translated_counts['rpm'] = count - translated_counts['srpm']
total_count['rpm'] = total_count['rpm'] ? total_count['rpm'] + translated_counts['rpm'] : translated_counts['rpm']
total_count['srpm'] = total_count['srpm'] ? total_count['srpm'] + translated_counts['srpm'] : translated_counts['srpm']
elsif name == 'container.manifest' && repo.content_counts['docker_manifest_list'] > 0
translated_counts['docker_manifest_list'] = repo_mirror_service.count_by_pulpcore_type(::Katello::Pulp3::DockerManifestList)
translated_counts['docker_manifest'] = count - translated_counts['docker_manifest_list']
else
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d47028

Please sign in to comment.