Skip to content

Conversation

@lfu
Copy link
Member

@lfu lfu commented Dec 8, 2025

What are the changes introduced in this pull request?

  • Add katello columns into Hosts Export CSV file
  • Add missing Manage columns to pagelet for CSV export.

Requires theforeman/foreman#10793

Considerations taken when implementing this change?

Change should work for both new hosts page and legacy UI page

What are the testing steps for this pull request?

Before this patch and theforeman/foreman#10793

  • Hosts - All Hosts - Legacy UI - Export - save the exported CSV file A
  • Hosts - All Hosts - Content Hosts - Export - save the exported CSV file B

After this patch and theforeman/foreman#10793

  • Hosts - All Hosts - Legacy UI - Export
    The exported file should be the same as the saved exported CSV file A

  • Hosts - All Hosts - Export
    The columns in the exported file should contain the columns exported from CSV file A + CSV file B

Summary by Sourcery

Extend host CSV export to include Katello-related data for the new hosts overview while loading required associations.

New Features:

  • Add Katello-specific CSV columns for errata counts, upgradable packages, content view environments, registration time, and last check-in on the new hosts hosts overview export.

Enhancements:

  • Ensure host exports preload Katello associations such as subscription facets, content facets, applicable RPMs, and content view environments.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • The request.path.start_with?('/new/hosts') checks in csv_columns and csv_headers are a bit brittle; consider using a more robust signal (e.g., a controller flag, route helper, or format/context check) to distinguish the new hosts overview from other hosts index endpoints.
  • The added Katello associations in included_associations will now be preloaded for all uses of this controller, not just CSV export or the new hosts overview; consider scoping this to only the relevant actions or formats to avoid unnecessary eager loading.
  • The Katello CSV column keys and headers are currently inlined in the methods; extracting them into named constants or helper methods would reduce duplication and make future changes to the CSV export schema easier to manage.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `request.path.start_with?('/new/hosts')` checks in `csv_columns` and `csv_headers` are a bit brittle; consider using a more robust signal (e.g., a controller flag, route helper, or format/context check) to distinguish the new hosts overview from other hosts index endpoints.
- The added Katello associations in `included_associations` will now be preloaded for all uses of this controller, not just CSV export or the new hosts overview; consider scoping this to only the relevant actions or formats to avoid unnecessary eager loading.
- The Katello CSV column keys and headers are currently inlined in the methods; extracting them into named constants or helper methods would reduce duplication and make future changes to the CSV export schema easier to manage.

## Individual Comments

### Comment 1
<location> `app/controllers/katello/concerns/hosts_controller_extensions.rb:56-59` </location>
<code_context>
       included do
         prepend Overrides

         def included_associations(include = [])
-          [:host_traces] + super
+          katello_associations = [:host_traces, :subscription_facet, :content_facet,
+                                  :applicable_rpms, :content_view_environments]
+          katello_associations + super
         end

</code_context>

<issue_to_address>
**issue (performance):** Broadly prepending multiple associations may introduce unnecessary eager loading and performance overhead.

These additional associations will now be eager loaded for every caller of this helper, not just the new use case. For endpoints that deal with large host sets (e.g., JSON index actions), this could noticeably increase query complexity and memory usage. If only some endpoints need these relations (e.g., CSV export), consider scoping the extra includes to those contexts instead of changing the default for all callers.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jeremylenz
Copy link
Member

@lfu lfu force-pushed the 38427_export_hosts branch 2 times, most recently from 13191a7 to c502b90 Compare December 12, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants