diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-09-28 02:23:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-28 02:23:45 +0200 |
commit | f0fff3eb1051ff77ec3f37aa75f8c56720b626a3 (patch) | |
tree | 7033a49d339bf8ff7ee4c96eb2d27ad40c9f4680 /app/models/feed.rb | |
parent | 3d7f68c273f03497ff555acac70355ba1815f7a2 (diff) |
Support min_id-based pagination in REST API (#8736)
* Allow min_id pagination in Feed#get * Add min_id pagination to home and list timeline APIs * Add min_id pagination to account statuses, public and tag APIs * Remove unused stub in reports API * Use min_id pagination in notifications, favourites, and fix order * Fix HomeFeed#from_database not using paginate_by_id
Diffstat (limited to 'app/models/feed.rb')
-rw-r--r-- | app/models/feed.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/models/feed.rb b/app/models/feed.rb index d99f1ffb2..5bce88f25 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -6,16 +6,20 @@ class Feed @id = id end - def get(limit, max_id = nil, since_id = nil) - from_redis(limit, max_id, since_id) + def get(limit, max_id = nil, since_id = nil, min_id = nil) + from_redis(limit, max_id, since_id, min_id) end protected - def from_redis(limit, max_id, since_id) - 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).map(&:first).map(&:to_i) + def from_redis(limit, max_id, since_id, min_id) + if min_id.blank? + 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).map(&:first).map(&:to_i) + else + unhydrated = redis.zrangebyscore(key, "(#{min_id}", '+inf', limit: [0, limit], with_scores: true).map(&:first).map(&:to_i) + end Status.where(id: unhydrated).cache_ids end |