-
Notifications
You must be signed in to change notification settings - Fork 95
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 #38131 - Use #include? instead of Regexp substring match #940
base: master
Are you sure you want to change the base?
Conversation
Could we also sort at the db level to get first 100 resources sorted by that key rather than a random subset of 100 resources which is then sorted?
I would be fine with that if we reworded the ui
I don't really see why anyone would pick an audit or a template invocation so I'd be fine with letting this slide, as long as it works for the more common resources - hosts, subnets and so on |
9dbebe0
to
5581e73
Compare
JS failures seem to be related :/ |
5581e73
to
e7d11db
Compare
@adamruzicka, 🍏 any comments? @MariaAga, could you please check if I didn't mess the UI part? |
const { perPage } = useForemanSettings(); | ||
const maxResults = perPage; |
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.
So we can just use perPage and remove maxResults?
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.
or since max results is already used everywhere here we can keep it actually
e7d11db
to
b14a2cd
Compare
return selectOptions.filter( | ||
o => | ||
typeof o.props.children === 'string' && | ||
o.props.children.toLowerCase().indexOf(value.toLowerCase()) > -1 |
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.
Results from API are being returned regardless of casing. This is to support case insensitivity in UI.
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.
Approve now also with case insensitive 🥳
This PR only replaces
=~
withinclude?
leaving the current behavior as is.We could go extra mile with this in terms of optimizing:
This will take only 100 items from DB which match the param. There are some downsides though:
to_s
on each. Depending on exact implementation it always will return a string with at least something to compare with the param. This approach uses DB search, so we can compare only string column and if they are present at all. This can be workarounded, but will require more changes. Not sure if it's worth for some entities such asAudit
orTemplateInvocation
, whereAudit.any.to_s
produces basically unusable string andTemplateInvocation.any.to_s
produces just a string with id of the object, which I don't find useful in context of template inputs. See screenshots:Before:
After:
It'll fail internally with error, since it tries
~
operator on an integer column.