ids_from_string abstracttion

This commit is contained in:
Alexander Meindl 2023-01-21 10:35:52 +01:00
parent 8029ec21a6
commit 801e292020
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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