|
|
|
@ -7,7 +7,7 @@ module Submissions
|
|
|
|
|
|
|
|
|
|
|
|
module_function
|
|
|
|
module_function
|
|
|
|
|
|
|
|
|
|
|
|
def search(submissions, keyword)
|
|
|
|
def search(submissions, keyword, search_values: false)
|
|
|
|
return submissions if keyword.blank?
|
|
|
|
return submissions if keyword.blank?
|
|
|
|
|
|
|
|
|
|
|
|
term = "%#{keyword.downcase}%"
|
|
|
|
term = "%#{keyword.downcase}%"
|
|
|
|
@ -18,6 +18,8 @@ module Submissions
|
|
|
|
.or(arel_table[:phone].matches(term))
|
|
|
|
.or(arel_table[:phone].matches(term))
|
|
|
|
.or(arel_table[:name].lower.matches(term))
|
|
|
|
.or(arel_table[:name].lower.matches(term))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arel = arel.or(Arel::Table.new(:submitters)[:values].matches(term)) if search_values
|
|
|
|
|
|
|
|
|
|
|
|
submissions.joins(:submitters).where(arel).distinct
|
|
|
|
submissions.joins(:submitters).where(arel).distinct
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|