API pagination for all collections using Link header
This commit is contained in:
parent
8d7fc5da6c
commit
b13e7dda1f
13 changed files with 123 additions and 63 deletions
|
@ -12,11 +12,13 @@ class Feed
|
|||
# If we're after most recent items and none are there, we need to precompute the feed
|
||||
if unhydrated.empty? && max_id == '+inf' && since_id == '-inf'
|
||||
RegenerationWorker.perform_async(@account.id, @type)
|
||||
Status.send("as_#{@type}_timeline", @account).paginate_by_max_id(limit, nil, nil)
|
||||
@statuses = Status.send("as_#{@type}_timeline", @account).paginate_by_max_id(limit, nil, nil)
|
||||
else
|
||||
status_map = Status.where(id: unhydrated).with_includes.with_counters.map { |status| [status.id, status] }.to_h
|
||||
unhydrated.map { |id| status_map[id] }.compact
|
||||
@statuses = unhydrated.map { |id| status_map[id] }.compact
|
||||
end
|
||||
|
||||
@statuses
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue