Skip to content

Commit

Permalink
Fixes #37396 - Fix autocomplete for ArfReports (#567)
Browse files Browse the repository at this point in the history
* Fixes #37396 - Fix autocomplete for ArfReports

The code expected that a host would have up to one lifecycle
environment, which doesn't hold anymore on recent versions of katello.
This tripped up scoped_search which couldn't find the right association
to search on.

* Fixes #37396 - Fix search on lifecycle_environments

We have to elaborate a bit on the associations to make scoped_search be
able to put the search together through the entire chain of the associations.
  • Loading branch information
adamruzicka authored May 15, 2024
1 parent 4b607c8 commit 868769f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ def apply_condition(scope, negate, conditions)

included do
if ForemanOpenscap.with_katello?
has_one :lifecycle_environment, :through => :host
has_one :content_facet, :through => :host
has_many :content_view_environment_content_facets, through: :content_facet, class_name: 'Katello::ContentViewEnvironmentContentFacet'
has_many :content_view_environments, through: :content_view_environment_content_facets
has_many :content_views, through: :content_view_environments
has_many :lifecycle_environments, through: :content_view_environments

has_many :host_collections, :through => :host

scoped_search :relation => :lifecycle_environment, :on => :name, :complete_value => true, :rename => :lifecycle_environment
scoped_search :relation => :lifecycle_environments, :on => :name, :complete_value => true, :rename => :lifecycle_environment
scoped_search :relation => :host_collections, :on => :name, :complete_value => true, :rename => :host_collection,
:operators => ['= ', '!= '], :ext_method => :search_by_host_collection_name
end
Expand Down

0 comments on commit 868769f

Please sign in to comment.