logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

feed.rb (628B)


  1. # frozen_string_literal: true
  2. class Feed
  3. def initialize(type, id)
  4. @type = type
  5. @id = id
  6. end
  7. def get(limit, max_id = nil, since_id = nil)
  8. from_redis(limit, max_id, since_id)
  9. end
  10. protected
  11. def from_redis(limit, max_id, since_id)
  12. max_id = '+inf' if max_id.blank?
  13. since_id = '-inf' if since_id.blank?
  14. unhydrated = redis.zrevrangebyscore(key, "(#{max_id}", "(#{since_id}", limit: [0, limit], with_scores: true).map(&:first).map(&:to_i)
  15. Status.where(id: unhydrated).cache_ids
  16. end
  17. def key
  18. FeedManager.instance.key(@type, @id)
  19. end
  20. def redis
  21. Redis.current
  22. end
  23. end