28efe28f24
Lean on ActiveRecord models for searching and strip out the raw SQL. Replaces the search_index_* tables with sharded search_records_* tables as that allows us to use a Search::Record model name. A Class is dynamically created for each record table shard so that we and we can access it via the Search::Record.for_account(account_id) method.
31 lines
522 B
Ruby
31 lines
522 B
Ruby
module Card::Searchable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
include ::Searchable
|
|
|
|
scope :mentioning, ->(query, user:) do
|
|
search_records = Search::Record.for_account(user.account_id)
|
|
|
|
joins(search_records.card_join)
|
|
.merge(search_records.for_query(query: Search::Query.wrap(query), user: user))
|
|
end
|
|
end
|
|
|
|
def search_title
|
|
title
|
|
end
|
|
|
|
def search_content
|
|
description.to_plain_text
|
|
end
|
|
|
|
def search_card_id
|
|
id
|
|
end
|
|
|
|
def search_board_id
|
|
board_id
|
|
end
|
|
end
|