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
Search feature for provisioning instance and virtual machines #22996
Conversation
@kbrock Please review |
app/models/miq_template.rb
Outdated
@@ -32,6 +32,10 @@ def self.eligible_for_provisioning | |||
where(:type => subclasses_supporting(:provisioning).map(&:name)).active | |||
end | |||
|
|||
def self.search(name) | |||
where('vms.name like ?', "%#{name}%") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this breaks when we search for something like - cent%
Started POST "/vm_cloud/vm_pre_prov/new?search_text=cent%&hide_deprecated_templates=true" for ::1 at 2024-04-17 19:40:06 +0530
[----] F, [2024-04-17T19:40:06.866328 #13781:ece0] FATAL -- :
ActionController::BadRequest (Invalid query parameters: invalid %-encoding (cent%)):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Fryguy , I had made a small change here in the ui side which helps to handle the search with % in the string.
b62601a
to
71899d6
Compare
app/models/miq_template.rb
Outdated
@@ -32,6 +32,10 @@ def self.eligible_for_provisioning | |||
where(:type => subclasses_supporting(:provisioning).map(&:name)).active | |||
end | |||
|
|||
def self.filter_with_name(name) | |||
where("vms.name ILIKE ?", "%#{name}%") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to be that guy...
Can we do:
where("vms.name ILIKE ?", "%#{name}%") | |
where(arel_table[:name].matches("%#{name}%")) |
The last 2 parameters defaulting to ("%#{name}%", nil, false)
-- meaning that we want a case insensitive LIKE
matching.
see also: https://rubydoc.info/docs/rails/6.0.2.1/Arel/Nodes/Matches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kbrock , I made the change and tested it. looks good..
8770304
to
10ff7c2
Compare
Hi @jeffibm , I hope the checks are successfully, can you please guide me how to do this in manageiq petrosian ? |
I have no idea how do it now. However, you will have to wait till these PRs are thoroughly reviewed, merged, and then backported to We will notify you once it's done. |
10ff7c2
to
975b91c
Compare
Checked commit jeffibm@975b91c with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
Dependant PR - ManageIQ/manageiq-ui-classic#9159