From e754b5bf9284c2ee54f689ba504d7993912f528c Mon Sep 17 00:00:00 2001 From: Jose Farias Date: Thu, 17 Oct 2024 17:38:33 -0600 Subject: [PATCH] Move all of Bubble's searchable concerns into Searchable --- app/models/bubble.rb | 3 --- app/models/bubble/searchable.rb | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/bubble.rb b/app/models/bubble.rb index 1e7b4ebef..c321653bc 100644 --- a/app/models/bubble.rb +++ b/app/models/bubble.rb @@ -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 } diff --git a/app/models/bubble/searchable.rb b/app/models/bubble/searchable.rb index dd951899c..c85cb4ea5 100644 --- a/app/models/bubble/searchable.rb +++ b/app/models/bubble/searchable.rb @@ -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