From 04bbc576906ff70feed7d42fef0e6db17fdd9ed3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 19 Oct 2016 18:20:19 +0200 Subject: Fix #100 - Add "back" button to certain views Also fix reloading of timelines after merge-type events --- app/models/feed.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'app/models/feed.rb') 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 -- cgit