0
0
Fork 0

Fix #100 - Add "back" button to certain views

Also fix reloading of timelines after merge-type events
This commit is contained in:
Eugen Rochko 2016-10-19 18:20:19 +02:00
parent 8698cd3281
commit 04bbc57690
10 changed files with 80 additions and 31 deletions

View file

@ -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