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

Parse input as numeric when a numeric comparison is requested #663

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion app/models/advanced_searches/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,24 @@ def modified_param_for_operation_type(operation_type, param)
else
'%s'
end
sprintf(fragment, param)

if is_numeric_operation?(operation_type)
sprintf(fragment, param.to_f)
else
sprintf(fragment, param)
end
end

def is_numeric_operation?(operation)
[
'is_above',
'is_below',
'is_less_than',
'is_greater_than',
'is_greater_than_or_equal_to',
'is_less_than_or_equal_to',
'is_in_the_range'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're missing is_equal (or whatever the equivalent is).

].include?(operation)
end
end
end