From 3a54126651bf81f17a3ebcb638cf24fedb098c63 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sat, 24 Aug 2019 21:55:30 -0500 Subject: avoid unneccesary scoping for self-searches; make sure general scope is limited to self/mentions/mutuals --- app/models/status.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'app/models/status.rb') diff --git a/app/models/status.rb b/app/models/status.rb index ff37f2bd8..02bc3ee94 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -36,8 +36,6 @@ # class Status < ApplicationRecord - self.ignored_columns = %w(tsv) - before_destroy :unlink_from_conversations include Paginable @@ -341,18 +339,17 @@ class Status < ApplicationRecord return none if account.nil? if term.start_with?('me:') term = term.split(nil, 2)[1] - scope = account.statuses + query = account.statuses else - scope = Status + mutual_account_ids = account.following_ids & account.follower_ids + query = Status.where(account_id: account.id) + .or(Status.where(account_ids: mutual_account_ids, visibility: [:private, :local, :unlisted])) + .or(Status.where(id: account.mentions.select(:status_id))) end return none if term.blank? pattern = sanitize_sql_like(term) pattern = "#{pattern}" - scope = scope.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern) - query = scope.where(account: account) - .or(scope.where(account: account.following, visibility: [:private, :local, :unlisted])) - .or(scope.where(id: account.mentions.select(:status_id))) - .limit(limit) + query = query.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern).limit(limit) apply_timeline_filters(query, account, true) end -- cgit