Add report for collecting Katello content facts#986
Add report for collecting Katello content facts#986ehelms merged 3 commits intotheforeman:masterfrom
Conversation
ccb9963 to
59cba93
Compare
|
Edit: updated to have "count" at the ends of the data fields. |
59cba93 to
1064787
Compare
1064787 to
3ab3188
Compare
|
Updated and still working: |
3ab3188 to
53400a8
Compare
adamruzicka
left a comment
There was a problem hiding this comment.
Seems to work well, although it could be made a bit DRYer, but that might be just personal preference.
definitions/reports/content.rb
Outdated
| query = | ||
| query( | ||
| <<-SQL | ||
| SELECT count(*) as yum_rh_count FROM "katello_root_repositories" | ||
| INNER JOIN "katello_products" ON "katello_products"."id" = "katello_root_repositories"."product_id" | ||
| INNER JOIN "katello_providers" ON "katello_providers"."id" = "katello_products"."provider_id" | ||
| WHERE "katello_providers"."provider_type" = 'Red Hat' | ||
| AND "katello_root_repositories"."content_type" = 'yum' | ||
| SQL | ||
| ) | ||
| query.first['yum_rh_count'].to_i |
There was a problem hiding this comment.
nitpick: This could still be using the sql_count helper
definitions/reports/content.rb
Outdated
| def library_container_repositories | ||
| sql_count("katello_root_repositories WHERE content_type = 'docker'") | ||
| end | ||
|
|
||
| def library_ostree_repositories | ||
| sql_count("katello_root_repositories WHERE content_type = 'ostree'") | ||
| end | ||
|
|
||
| def library_ansible_collection_repositories | ||
| sql_count("katello_root_repositories WHERE content_type = 'ansible_collection'") | ||
| end | ||
|
|
||
| def library_file_repositories | ||
| sql_count("katello_root_repositories WHERE content_type = 'file'") | ||
| end | ||
|
|
||
| def library_python_repositories | ||
| sql_count("katello_root_repositories WHERE content_type = 'python'") | ||
| end | ||
|
|
||
| def library_debian_repositories | ||
| sql_count("katello_root_repositories WHERE content_type = 'deb'") | ||
| end |
There was a problem hiding this comment.
nitpick: While this works, it feels a bit repetitive
|
I can clean these ^ up a bit. |
|
I've updated the content.rb file. It isn't tested yet. |
adamruzicka
left a comment
There was a problem hiding this comment.
Seems to work well, rubocop is unhappy though
definitions/reports/content.rb
Outdated
| "katello_root_repositories" | ||
| WHERE "katello_root_repositories"."id" NOT IN | ||
| (SELECT "katello_root_repositories"."id" FROM "katello_root_repositories" INNER JOIN "katello_products" | ||
| ON "katello_products"."id" = "katello_root_repositories"."product_id" INNER JOIN "katello_providers" | ||
| ON "katello_providers"."id" = "katello_products"."provider_id" WHERE "katello_providers"."provider_type" = 'Red Hat') | ||
| AND "katello_root_repositories"."content_type" = 'yum' |
There was a problem hiding this comment.
Out of curiosity, is there a reason for going with a subquery directly joining all the necessary tables and then filtering out the rows we don't want to count?
There was a problem hiding this comment.
I grabbed these queries directly from Katello & to_sql. Could be simplified perhaps.
a270a47 to
283d25c
Compare
Begins Katello content fact collection for the analytics report. Starts with repository type information.
Example output:
Also adds some alternate content source fact collection: