diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-03 18:21:26 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-03 18:21:26 +0100 |
commit | 816284d73924ceb453c76d571bcb315be91b2b08 (patch) | |
tree | 2fbf97bed916b582600e333c591d74c40f308111 /app/models/status.rb | |
parent | 253970cb736a4da29229b930a0af32ead7e5d99b (diff) |
Fix #248 - Reload all accounts when fetching from cache
Diffstat (limited to 'app/models/status.rb')
-rw-r--r-- | app/models/status.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 1e70101a3..f6d8fc9bb 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -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) |