Files
fizzy/app/models/bubble/searchable.rb
T
2024-10-17 21:34:48 -06:00

18 lines
483 B
Ruby

module Bubble::Searchable
extend ActiveSupport::Concern
included do
include ::Searchable
searchable_by :title, using: :bubbles_search_index
scope :mentioning, ->(query) do
if query = query.presence
bubbles = search(query).select(:id).to_sql
comments = Comment.search(query).select(:bubble_id).to_sql
left_joins(:comments).where("bubbles.id in (#{bubbles}) or comments.bubble_id in (#{comments})").distinct
end
end
end
end