mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-09 00:49:07 +08:00
Fix gloabl search for tables [SCI-10152]
This commit is contained in:
parent
44dca8dd7c
commit
a4475b8dca
3 changed files with 7 additions and 6 deletions
|
@ -187,8 +187,8 @@ module SearchableModel
|
|||
"#{a} IS NOT NULL AND (((#{a})::text) #{like} :t#{i}) OR "
|
||||
elsif defined?(model::PREFIXED_ID_SQL) && a == model::PREFIXED_ID_SQL
|
||||
"#{a} IS NOT NULL AND (#{a} #{like} :t#{i}) OR "
|
||||
elsif a == 'asset_text_data.data_vector'
|
||||
"asset_text_data.data_vector @@ plainto_tsquery(:t#{i})) OR"
|
||||
elsif ['asset_text_data.data_vector', 'tables.data_vector'].include?(a)
|
||||
"#{a} @@ plainto_tsquery(:t#{i}) OR "
|
||||
else
|
||||
"#{a} IS NOT NULL AND ((trim_html_tags(#{a})) #{like} :t#{i}) OR "
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class Protocol < ApplicationRecord
|
|||
include ArchivableModel
|
||||
include PrefixedIdModel
|
||||
SEARCHABLE_ATTRIBUTES = ['protocols.name', 'protocols.description', PREFIXED_ID_SQL, 'steps.name',
|
||||
'step_texts.name', 'step_texts.text', 'tables.name',
|
||||
'step_texts.name', 'step_texts.text', 'tables.name', 'tables.data_vector',
|
||||
'checklists.name', 'checklist_items.text', 'comments.message'].freeze
|
||||
REPOSITORY_TYPES = %i(in_repository_published_original in_repository_draft in_repository_published_version).freeze
|
||||
|
||||
|
@ -204,8 +204,9 @@ class Protocol < ApplicationRecord
|
|||
.where(protocol: raw_input)
|
||||
.where_attributes_like_boolean(['steps.name', 'step_texts.name',
|
||||
'step_texts.text', 'tables.name',
|
||||
'comments.message', 'checklists.name',
|
||||
'checklist_items.text'], query)
|
||||
'tables.data_vector', 'comments.message',
|
||||
'checklists.name', 'checklist_items.text'],
|
||||
query)
|
||||
.select(:protocol_id)))
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class Result < ApplicationRecord
|
|||
validates :name, length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
|
||||
SEARCHABLE_ATTRIBUTES = ['results.name', 'result_texts.name', 'result_texts.text',
|
||||
'tables.name', 'comments.message'].freeze
|
||||
'tables.name', 'tables.data_vector', 'comments.message'].freeze
|
||||
|
||||
enum assets_view_mode: { thumbnail: 0, list: 1, inline: 2 }
|
||||
|
||||
|
|
Loading…
Reference in a new issue