Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35901 - Allow searching for CCVs based on component CVs #10767

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

jeremylenz
Copy link
Member

What are the changes introduced in this pull request?

Add a new field to Content View scoped_search. This will allow you to search for a composite content view that contains a particular content view.

For example:

content_views = My-Content_view

will return composite content views that have My-Content_view as one of their components.

Considerations taken when implementing this change?

I'm still not sure about any performance implications; suggestions welcome

What are the testing steps for this pull request?

Create at least one composite CV but preferably hundreds lol
Search on the Content Views page
Make sure everything works as expected

Comment on lines +127 to +134
def self.completer_scope_options(search)
if search.include?('content_views')
# Don't autocomplete CCV names when searching for components
{ :value_filter => { :composite => false } }
else
{}
end
end
Copy link
Member Author

Choose a reason for hiding this comment

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

Autocomplete was including composite CV names in the suggested search. For example, if I was searching for content_views = xxx and had typed content_views = , the suggestions would include all of my content view names, including composite content views. But a composite content view cannot contain itself, so this made no sense. To prevent this I added this method, which modifies scoped_search's value filter. I had to modify it to pass in the search because otherwise it would filter out composite CVs when I searched for name = , which we don't want.

@@ -111,6 +111,27 @@ class ContentView < Katello::Model
scoped_search :on => :composite, :complete_value => true
scoped_search :on => :generated_for, :complete_value => true
scoped_search :on => :default # just for ordering
scoped_search :on => :name, :complete_value => true,
:rename => :content_views,
:operators => ['=', '!=', '~', '!~'],
Copy link
Member Author

Choose a reason for hiding this comment

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

I filtered out the operators like < that don't make much sense here, as well as ^ which just don't seem to work well for this use case

@@ -111,6 +111,27 @@ class ContentView < Katello::Model
scoped_search :on => :composite, :complete_value => true
scoped_search :on => :generated_for, :complete_value => true
scoped_search :on => :default # just for ordering
scoped_search :on => :name, :complete_value => true,
:rename => :content_views,
Copy link
Member Author

Choose a reason for hiding this comment

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

I considered naming this components, but we've moved away from using the "component" terminology recently, and I don't want to reverse that.

@jeremylenz jeremylenz force-pushed the 35901-content-view-inception branch 2 times, most recently from def1eaf to d65fbc1 Compare October 12, 2023 20:11
@jeremylenz
Copy link
Member Author

fixed rubocop & added unused method args

@jeremylenz
Copy link
Member Author

[test katello]

1 similar comment
@jeremylenz
Copy link
Member Author

[test katello]

@sjha4
Copy link
Member

sjha4 commented Oct 13, 2023

The ~ operator seems to be acting weird with content_views..

Screenshot from 2023-10-13 13-03-13
Screenshot from 2023-10-13 13-02-51
Screenshot from 2023-10-13 13-02-24

@jeremylenz jeremylenz force-pushed the 35901-content-view-inception branch from d65fbc1 to 12af004 Compare October 13, 2023 19:10
@jeremylenz jeremylenz force-pushed the 35901-content-view-inception branch from 12af004 to 46d1545 Compare October 13, 2023 19:54
@jeremylenz
Copy link
Member Author

Updated to only suggest the = operator, per our discussion 👍

Copy link
Member

@sjha4 sjha4 left a comment

Choose a reason for hiding this comment

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

Ack.. 👍🏼
Works as expected with = operator. Ignoring other operators for now and as discussed offline, those can be revisited if someone needs it and it's deemed worthwhile to add custom operator queries for those..

@jeremylenz jeremylenz merged commit c6064c9 into Katello:master Oct 13, 2023
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