Fix matching scope after merge
This commit is contained in:
@@ -23,8 +23,8 @@ class Search::Record < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
scope :matching, ->(query) do
|
||||
matching_scope(query)
|
||||
scope :matching, ->(query, account_id) do
|
||||
matching_scope(query, account_id)
|
||||
end
|
||||
|
||||
scope :for_user, ->(user) do
|
||||
|
||||
@@ -15,7 +15,7 @@ module Search::Record::SQLite
|
||||
self
|
||||
end
|
||||
|
||||
def matching_scope(query)
|
||||
def matching_scope(query, account_id)
|
||||
joins("INNER JOIN search_records_fts ON search_records_fts.rowid = #{table_name}.id")
|
||||
.where("search_records_fts MATCH ?", query)
|
||||
end
|
||||
|
||||
@@ -30,9 +30,11 @@ module Search::Record::Trilogy
|
||||
Zlib.crc32(account_id.to_s) % SHARD_COUNT
|
||||
end
|
||||
|
||||
def matching_scope(query)
|
||||
def matching_scope(query, account_id)
|
||||
stemmed_query = Search::Stemmer.stem(query)
|
||||
where("MATCH(#{table_name}.content, #{table_name}.title) AGAINST(? IN BOOLEAN MODE)", stemmed_query)
|
||||
account_key = "account#{account_id}"
|
||||
full_query = "+#{account_key} +(#{stemmed_query})"
|
||||
where("MATCH(#{table_name}.account_key, #{table_name}.content, #{table_name}.title) AGAINST(? IN BOOLEAN MODE)", full_query)
|
||||
end
|
||||
|
||||
def search_scope(relation, query)
|
||||
|
||||
Reference in New Issue
Block a user