From 9c9c17bb47536674ff3729914cdf08f1de680dee Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Tue, 24 Jun 2025 13:47:52 +0200 Subject: [PATCH] Extract common markup to constants --- app/models/search.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/search.rb b/app/models/search.rb index d671f4443..46d5403fc 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -1,6 +1,9 @@ class Search attr_reader :user, :query + HIGHLIGHT_OPENING_MARK = "" + HIGHLIGHT_CLOSING_MARK = "" + def self.table_name_prefix "search_" end @@ -17,8 +20,8 @@ class Search .select([ "cards.id as card_id", "null as comment_id", - "highlight(cards_search_index, 0, '', '') AS card_title", - "snippet(cards_search_index, 1, '', '', '...', 20) AS card_description", + "highlight(cards_search_index, 0, '#{HIGHLIGHT_OPENING_MARK}', '#{HIGHLIGHT_CLOSING_MARK}') AS card_title", + "snippet(cards_search_index, 1, '#{HIGHLIGHT_OPENING_MARK}', '#{HIGHLIGHT_CLOSING_MARK}', '...', 20) AS card_description", "null as comment_body", "collections.name as collection_name", "cards.creator_id", @@ -31,7 +34,7 @@ class Search "comments.id as comment_id", "cards.title AS card_title", "null AS card_description", - "snippet(comments_search_index, 0, '', '', '...', 20) AS comment_body", + "snippet(comments_search_index, 0, '#{HIGHLIGHT_OPENING_MARK}', '#{HIGHLIGHT_CLOSING_MARK}', '...', 20) AS comment_body", "collections.name as collection_name", "comments.creator_id", "bm25(comments_search_index, 1.0) AS score"