Move all of Bubble's searchable concerns into Searchable
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user