about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-04-13 23:32:41 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:21 -0500
commit16147d73a26e8935897795a05423eba3a1ee78d2 (patch)
tree5d48018c5c10eb41e070c2c45c623a015151eaaf /app/models
parentdd5e02ad5d79e4fc2163a9bcd009859e9c2a4466 (diff)
`Status.search_for`: Don't need `Status.unscoped`; the `default_scope` sorts the way we intend.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb22
1 files changed, 10 insertions, 12 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 7679fd60f..c134926c8 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -301,18 +301,16 @@ class Status < ApplicationRecord
     def search_for(term, limit = 33, account = nil)
       pattern = sanitize_sql_like(term)
       pattern = "#{pattern}"
-      Status.unscoped {
-        scope = Status.where("tsv @@ plainto_tsquery('english', ?)", pattern)
-        query = scope.where(visibility: :public)
-        if account.present?
-          query = query
-            .or(scope.where(account: account))
-            .or(scope.where(account: account.following, visibility: [:unlisted, :private]))
-            .or(scope.where(id: account.mentions.select(:status_id)))
-        end
-        query = query.where(reblog_of_id: nil).order(id: :desc).limit(limit)
-        apply_timeline_filters(query, account, true)
-      }
+      scope = Status.where("tsv @@ plainto_tsquery('english', ?)", pattern)
+      query = scope.where(visibility: :public)
+      if account.present?
+        query = query
+          .or(scope.where(account: account))
+          .or(scope.where(account: account.following, visibility: [:unlisted, :private]))
+          .or(scope.where(id: account.mentions.select(:status_id)))
+      end
+      query = query.where(reblog_of_id: nil).limit(limit)
+      apply_timeline_filters(query, account, true)
     end
 
     def selectable_visibilities