Update app/controllers/universal_tables_controller.rb

changed to full string search instead of splitting words
This commit is contained in:
Harry Bomrah 2024-08-22 12:59:25 +00:00
parent 7c4102d61b
commit fc39a817ab
1 changed files with 7 additions and 6 deletions

View File

@ -258,12 +258,13 @@ class UniversalTablesController < ApplicationController
q.each do |k, v| q.each do |k, v|
column = table.table_columns.where(:key => k).first column = table.table_columns.where(:key => k).first
next if column.nil? next if column.nil?
if column.make_categorizable # if column.make_categorizable
# regex = Regexp.new(".*"+v+".*", "i")
# else
# regexes = v.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
# regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
# end
regex = Regexp.new(".*"+v+".*", "i") regex = Regexp.new(".*"+v+".*", "i")
else
regexes = v.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
end
if column.type == "text" if column.type == "text"
columns = column.column_entries.any_of([{"text.en" => regex}, {"text.zh_tw" => regex}]) columns = column.column_entries.any_of([{"text.en" => regex}, {"text.zh_tw" => regex}])
elsif column.type == "editor" elsif column.type == "editor"