-
Notifications
You must be signed in to change notification settings - Fork 992
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 #29683 - fix params search on hg,os,domain,subnet pages #7670
Conversation
Issues: #29683 |
bac8bde
to
d347e54
Compare
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.
see comments inline. can you add some tests as well please?
if respond_to?(:with_taxonomy_scope) | ||
build_query = build_query.with_taxonomy_scope | ||
end | ||
resource_ids = build_query.joins(parameters_relation).where(conditions).map(&:id).flatten.uniq |
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.
I think this might be faster:
resource_ids = build_query.joins(parameters_relation).where(conditions).map(&:id).flatten.uniq | |
resource_ids = build_query.joins(parameters_relation).where(conditions).distinct.pluck(:id) |
as it doesn't load all objects to memory but rather pulls the ids directly from the db
conditions = sanitize_sql_for_conditions( | ||
["parameters.name = ? and parameters.searchable_value #{operator} ?", key_name, value_to_sql(operator, value)] | ||
) | ||
build_query = unscoped |
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.
what about authorization? or would that be added anyways by the controller after the search scope?
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.
Yes, at controller level it uses resource_base
which calls authorized
if that method exists on model.
end | ||
resource_ids = build_query.joins(parameters_relation).where(conditions).map(&:id).flatten.uniq | ||
|
||
opts = "#{table_name}.id < 0" |
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.
opts = "#{table_name}.id < 0" | |
opts = "1 < 0" |
will get the same result without checking the table index
end | ||
|
||
def parameter_relation_symbol | ||
case to_s |
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.
@tbrisker,
Here, I changed method class_name
to to_s
as it was failing for class_name
method while running tests.
@kgaikwad please rebase. |
f753ec7
to
18e0382
Compare
@shiramax, done with rebase! |
Any progress on this? |
18e0382
to
8a94b78
Compare
@shiramax, it's green :) 🍏 |
No description provided.