about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 1e70101a3..1f5cf9b46 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -94,11 +94,11 @@ class Status < ApplicationRecord
 
   class << self
     def as_home_timeline(account)
-      where(account: [account] + account.following).with_includes
+      where(account: [account] + account.following)
     end
 
     def as_mentions_timeline(account)
-      where(id: Mention.where(account: account).pluck(:status_id)).with_includes
+      where(id: Mention.where(account: account).select(:status_id))
     end
 
     def as_public_timeline(account = nil)
@@ -130,6 +130,22 @@ class Status < ApplicationRecord
       select('reblog_of_id').where(reblog_of_id: status_ids).where(account_id: account_id).map { |s| [s.reblog_of_id, true] }.to_h
     end
 
+    def reload_stale_associations!(cached_items)
+      account_ids = []
+
+      cached_items.each do |item|
+        account_ids << item.account_id
+        account_ids << item.reblog.account_id if item.reblog?
+      end
+
+      accounts = Account.where(id: account_ids.uniq).map { |a| [a.id, a] }.to_h
+
+      cached_items.each do |item|
+        item.account = accounts[item.account_id]
+        item.reblog.account = accounts[item.reblog.account_id] if item.reblog?
+      end
+    end
+
     private
 
     def filter_timeline(query, account)