Merge pull request #7595 from rekonder/aj_SCI_10152

Fix global search for tables [SCI-10152]
This commit is contained in:
ajugo 2024-05-24 11:30:15 +02:00 committed by GitHub
commit dab6fb7056
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

View file

@ -187,8 +187,8 @@ module SearchableModel
"#{a} IS NOT NULL AND (((#{a})::text) #{like} :t#{i}) OR " "#{a} IS NOT NULL AND (((#{a})::text) #{like} :t#{i}) OR "
elsif defined?(model::PREFIXED_ID_SQL) && a == model::PREFIXED_ID_SQL elsif defined?(model::PREFIXED_ID_SQL) && a == model::PREFIXED_ID_SQL
"#{a} IS NOT NULL AND (#{a} #{like} :t#{i}) OR " "#{a} IS NOT NULL AND (#{a} #{like} :t#{i}) OR "
elsif a == 'asset_text_data.data_vector' elsif ['asset_text_data.data_vector', 'tables.data_vector'].include?(a)
"asset_text_data.data_vector @@ plainto_tsquery(:t#{i})) OR" "#{a} @@ plainto_tsquery(:t#{i}) OR "
else else
"#{a} IS NOT NULL AND ((trim_html_tags(#{a})) #{like} :t#{i}) OR " "#{a} IS NOT NULL AND ((trim_html_tags(#{a})) #{like} :t#{i}) OR "
end end

View file

@ -6,7 +6,7 @@ class Protocol < ApplicationRecord
include ArchivableModel include ArchivableModel
include PrefixedIdModel include PrefixedIdModel
SEARCHABLE_ATTRIBUTES = ['protocols.name', 'protocols.description', PREFIXED_ID_SQL, 'steps.name', 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 'checklists.name', 'checklist_items.text', 'comments.message'].freeze
REPOSITORY_TYPES = %i(in_repository_published_original in_repository_draft in_repository_published_version).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(protocol: raw_input)
.where_attributes_like_boolean(['steps.name', 'step_texts.name', .where_attributes_like_boolean(['steps.name', 'step_texts.name',
'step_texts.text', 'tables.name', 'step_texts.text', 'tables.name',
'comments.message', 'checklists.name', 'tables.data_vector', 'comments.message',
'checklist_items.text'], query) 'checklists.name', 'checklist_items.text'],
query)
.select(:protocol_id))) .select(:protocol_id)))
end end

View file

@ -10,7 +10,7 @@ class Result < ApplicationRecord
validates :name, length: { maximum: Constants::NAME_MAX_LENGTH } validates :name, length: { maximum: Constants::NAME_MAX_LENGTH }
SEARCHABLE_ATTRIBUTES = ['results.name', 'result_texts.name', 'result_texts.text', 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 } enum assets_view_mode: { thumbnail: 0, list: 1, inline: 2 }