0d138df952
Only index cards and comments if their card is `published?`, using a new method `searchable?` that is implemented on both Card and Comment. This prevents draft cards and their comments from being indexed. When drafts are published, the existing `update_in_search_index` callback creates the record via `upsert!`, or else ensures unpublished records are removed from the index. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
532 B
Ruby
33 lines
532 B
Ruby
module Card::Searchable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
include ::Searchable
|
|
|
|
scope :mentioning, ->(query, user:) do
|
|
search_record_class = Search::Record.for(user.account_id)
|
|
joins(search_record_class.card_join).merge(search_record_class.for_query(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
|
|
|
|
def searchable?
|
|
published?
|
|
end
|
|
end
|