about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-11-21 17:35:04 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-11-21 17:35:04 +0100
commit2edf6d81cba25555814046d7b9f260872c2c9545 (patch)
treed35ed3f40c8e397d1cf1659f1e96b162d6646e96 /app
parentc656cc2191479551806d288bdfb6a30aa35bcb23 (diff)
Simplify SQL query when performing account search amongst followings (#12302)
Diffstat (limited to 'app')
-rw-r--r--app/models/account.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index cae82da16..d17782f78 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -436,7 +436,7 @@ class Account < ApplicationRecord
             accounts.*,
             (count(f.id) + 1) * ts_rank_cd(#{textsearch}, #{query}, 32) AS rank
           FROM accounts
-          LEFT OUTER JOIN follows AS f ON (accounts.id = f.account_id AND f.target_account_id = ?) OR (accounts.id = f.target_account_id AND f.account_id = ?)
+          LEFT OUTER JOIN follows AS f ON (accounts.id = f.account_id AND f.target_account_id = ?)
           WHERE accounts.id IN (SELECT * FROM first_degree)
             AND #{query} @@ #{textsearch}
             AND accounts.suspended_at IS NULL
@@ -446,7 +446,7 @@ class Account < ApplicationRecord
           LIMIT ? OFFSET ?
         SQL
 
-        records = find_by_sql([sql, account.id, account.id, account.id, account.id, limit, offset])
+        records = find_by_sql([sql, account.id, account.id, account.id, limit, offset])
       else
         sql = <<-SQL.squish
           SELECT