From 3e872ded3d414e16a788713cf52550e47a376455 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Mon, 7 Dec 2020 11:33:17 -0600 Subject: [PATCH] Parse input as numeric when a numeric comparison is requested --- app/models/advanced_searches/base.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/advanced_searches/base.rb b/app/models/advanced_searches/base.rb index 288142d1..bc1c9904 100644 --- a/app/models/advanced_searches/base.rb +++ b/app/models/advanced_searches/base.rb @@ -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' + ].include?(operation) end end end