about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2021-02-01 05:24:17 +0900
committerGitHub <noreply@github.com>2021-01-31 21:24:17 +0100
commitc8c764dd8b168ec876918d16b3f25280893d20dc (patch)
tree54817292eea5326a09771585045abbb61d21804c /app
parenteb0f9e315939a66ebad0b174beeb1edde7ba7e8d (diff)
Fix N+1 query when rendering with StatusSerializer (#15641)
Diffstat (limited to 'app')
-rw-r--r--app/models/status.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index fcc7a026d..74e81f612 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -114,7 +114,7 @@ class Status < ApplicationRecord
                    :tags,
                    :preview_cards,
                    :preloadable_poll,
-                   account: :account_stat,
+                   account: [:account_stat, :user],
                    active_mentions: { account: :account_stat },
                    reblog: [
                      :application,
@@ -124,7 +124,7 @@ class Status < ApplicationRecord
                      :conversation,
                      :status_stat,
                      :preloadable_poll,
-                     account: :account_stat,
+                     account: [:account_stat, :user],
                      active_mentions: { account: :account_stat },
                    ],
                    thread: { account: :account_stat }
@@ -301,7 +301,7 @@ class Status < ApplicationRecord
 
       return if account_ids.empty?
 
-      accounts = Account.where(id: account_ids).includes(:account_stat).index_by(&:id)
+      accounts = Account.where(id: account_ids).includes(:account_stat, :user).index_by(&:id)
 
       cached_items.each do |item|
         item.account = accounts[item.account_id]