fulltext search

This commit is contained in:
Pete Matsyburka
2025-06-05 13:16:55 +03:00
parent 9d1860f038
commit 33811945be
36 changed files with 682 additions and 25 deletions
+20 -1
View File
@@ -37,12 +37,31 @@ module Templates
hash
end
def search(templates, keyword)
def search(current_user, templates, keyword)
if Docuseal.fulltext_search?(current_user)
fulltext_search(current_user, templates, keyword)
else
plain_search(templates, keyword)
end
end
def plain_search(templates, keyword)
return templates if keyword.blank?
templates.where(Template.arel_table[:name].lower.matches("%#{keyword.downcase}%"))
end
def fulltext_search(current_user, templates, keyword)
return templates if keyword.blank?
templates.where(
id: SearchEntry.where(record_type: 'Template')
.where(account_id: current_user.account_id)
.where(*SearchEntries.build_tsquery(keyword))
.select(:record_id)
)
end
def filter_undefined_submitters(template_submitters)
template_submitters.to_a.select do |item|
item['invite_by_uuid'].blank? && item['optional_invite_by_uuid'].blank? &&