about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-22 22:59:54 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-22 22:59:54 +0100
commitfc90d38893ae81b83884c3f5c85d05d564f1de33 (patch)
tree8d881992a6afe8519277e6206c6289f574c00337 /app/models
parent4b5b953d4223776860bcccb56d2f9c7144dc302e (diff)
Moving some counter queries out of subqueries in the API
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 1bf4b49c9..53987c3ec 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -71,7 +71,7 @@ class Status < ApplicationRecord
 
   def ancestors(account = nil)
     ids      = (Status.find_by_sql(['WITH RECURSIVE search_tree(id, in_reply_to_id, path) AS (SELECT id, in_reply_to_id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, statuses.in_reply_to_id, path || statuses.id FROM search_tree JOIN statuses ON statuses.id = search_tree.in_reply_to_id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path DESC', id]) - [self]).pluck(:id)
-    statuses = Status.where(id: ids).with_counters.with_includes.group_by(&:id)
+    statuses = Status.where(id: ids).with_includes.group_by(&:id)
     results  = ids.map { |id| statuses[id].first }
     results  = results.reject { |status| account.blocking?(status.account) } unless account.nil?
 
@@ -80,7 +80,7 @@ class Status < ApplicationRecord
 
   def descendants(account = nil)
     ids      = (Status.find_by_sql(['WITH RECURSIVE search_tree(id, path) AS (SELECT id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, path || statuses.id FROM search_tree JOIN statuses ON statuses.in_reply_to_id = search_tree.id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path', id]) - [self]).pluck(:id)
-    statuses = Status.where(id: ids).with_counters.with_includes.group_by(&:id)
+    statuses = Status.where(id: ids).with_includes.group_by(&:id)
     results  = ids.map { |id| statuses[id].first }
     results  = results.reject { |status| account.blocking?(status.account) } unless account.nil?