ids_from_string abstracttion
This commit is contained in:
parent
8029ec21a6
commit
801e292020
@ -59,7 +59,7 @@ module AdditionalsQuery
|
||||
def sql_for_ids_field(_field, operator, value)
|
||||
if operator == '='
|
||||
# accepts a comma separated list of ids
|
||||
ids = value.first.to_s.scan(/\d+/).map(&:to_i)
|
||||
ids = Additionals.ids_from_string value.first
|
||||
if ids.any?
|
||||
"#{queried_table_name}.id IN (#{ids.join ','})"
|
||||
else
|
||||
|
@ -47,6 +47,10 @@ module Additionals
|
||||
[value, options]
|
||||
end
|
||||
|
||||
def ids_from_string(string)
|
||||
string.to_s.scan(/\d+/).map(&:to_i)
|
||||
end
|
||||
|
||||
def split_ids(phrase, limit: nil)
|
||||
limit ||= Setting.per_page_options_array.first || 25
|
||||
raw_ids = phrase.strip_split
|
||||
|
Loading…
Reference in New Issue
Block a user