diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/feed.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/app/models/feed.rb b/app/models/feed.rb index 4466ea14e..2bc9e980a 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -8,13 +8,12 @@ class Feed max_id = '+inf' if max_id.blank? since_id = '-inf' if since_id.blank? unhydrated = redis.zrevrangebyscore(key, "(#{max_id}", "(#{since_id}", limit: [0, limit], with_scores: true).collect(&:last).map(&:to_i) - status_map = {} # If we're after most recent items and none are there, we need to precompute the feed - if unhydrated.empty? && max_id == '+inf' + if unhydrated.empty? && max_id == '+inf' && since_id == '-inf' PrecomputeFeedService.new.call(@type, @account, limit) else - Status.where(id: unhydrated).with_includes.with_counters.each { |status| status_map[status.id] = status } + status_map = Status.where(id: unhydrated).with_includes.with_counters.map { |status| [status.id, status] }.to_h unhydrated.map { |id| status_map[id] }.compact end end |