about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-01-10 17:10:11 +0100
committerGitHub <noreply@github.com>2023-01-10 17:10:11 +0100
commit932a22219ae99a285bdd0b69f02627f029327db3 (patch)
tree5c211e2d230afa698ed4cc081c076251817b0d8d /app/models
parentad17e1944aa4c01c5637199b464c9d78b7e54af2 (diff)
parenta7bf439cfd12ec44c5da9d51e501e51fdfc12b54 (diff)
Merge pull request #2077 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 4a7219624..851ce1fd6 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -511,7 +511,8 @@ class Account < ApplicationRecord
         <<-SQL.squish
           SELECT
             accounts.*,
-            (count(f.id) + 1) * #{BOOST} * ts_rank_cd(#{TEXTSEARCH}, to_tsquery('simple', :tsquery), 32) AS rank
+            #{BOOST} * ts_rank_cd(#{TEXTSEARCH}, to_tsquery('simple', :tsquery), 32) AS rank,
+            count(f.id) AS followed
           FROM accounts
           LEFT OUTER JOIN follows AS f ON (accounts.id = f.account_id AND f.target_account_id = :id) OR (accounts.id = f.target_account_id AND f.account_id = :id)
           LEFT JOIN users ON accounts.id = users.account_id
@@ -521,7 +522,7 @@ class Account < ApplicationRecord
             AND accounts.moved_to_account_id IS NULL
             AND (accounts.domain IS NOT NULL OR (users.approved = TRUE AND users.confirmed_at IS NOT NULL))
           GROUP BY accounts.id, s.id
-          ORDER BY rank DESC
+          ORDER BY followed DESC, rank DESC
           LIMIT :limit OFFSET :offset
         SQL
       end