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 18, 2023
1 parent d16c8b1 commit 2de847a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
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 2de847a

Please sign in to comment.