about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-24 12:49:34 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-24 12:49:34 +0100
commit7e58303a8da90b31f4179695283d3ac19dfb09d1 (patch)
tree705a53da3f360379737293d234a52af1748ae312 /app/models
parentc8999a116ef71bef2cb28a783e4ba3d8e3cea6fa (diff)
Limit Atom feeds to 20 items by default, add pagination by max_id
(But there are no Atom feed pagination elements yet)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/stream_entry.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb
index 68a33ccf7..d64edd62f 100644
--- a/app/models/stream_entry.rb
+++ b/app/models/stream_entry.rb
@@ -4,7 +4,8 @@ class StreamEntry < ActiveRecord::Base
 
   validates :account, :activity, presence: true
 
-  scope :with_includes, -> { includes(:activity) }
+  scope :with_includes,      -> { includes(:activity) }
+  scope :paginate_by_max_id, -> (limit, max_id) { order('id desc').limit(limit).where(max_id.nil? ? '1=1' : ['id < ?', max_id]) }
 
   def object_type
     orphaned? ? :activity : (targeted? ? :activity : self.activity.object_type)