Move all of Bubble's searchable concerns into Searchable

This commit is contained in:
Jose Farias
2024-10-17 17:38:33 -06:00
parent 7e99aabaa1
commit e754b5bf92
2 changed files with 5 additions and 6 deletions
-3
View File
@@ -1,5 +1,4 @@
class Bubble < ApplicationRecord
include ::Searchable
include Assignable, Boostable, Colored, Commentable, Eventable, Poppable, Searchable, Taggable, Threaded
belongs_to :bucket
@@ -7,8 +6,6 @@ class Bubble < ApplicationRecord
has_one_attached :image, dependent: :purge_later
searchable_by :title, using: :bubbles_search_index
before_save :set_default_title
scope :reverse_chronologically, -> { order created_at: :desc, id: :desc }
+5 -3
View File
@@ -2,13 +2,15 @@ module Bubble::Searchable
extend ActiveSupport::Concern
included do
include ::Searchable
searchable_by :title, using: :bubbles_search_index
scope :mentioning, ->(query) do
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
left_joins(:comments).where("bubbles.id in (#{bubbles}) or comments.bubble_id in (#{comments})").distinct
end
end
end