浏览代码

Simplify SQL query when performing account search amongst followings (#12302)

master^2
ThibG 4 年前
committed by Eugen Rochko
父节点
当前提交
2edf6d81cb
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. +2
    -2
      app/models/account.rb

+ 2
- 2
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


正在加载...
取消
保存