about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorIan McCowan <imccowan@gmail.com>2018-02-25 18:31:28 -0800
committerEugen Rochko <eugen@zeonfederated.com>2018-02-26 03:31:28 +0100
commitc33931b613c7da4cc2c22ff8411c38556dc579cb (patch)
tree87b59f8a474cddad9d888b1f6499daf52da9fd2a /app/models
parent5cc716688abdf7eaafc58d804209510601190791 (diff)
Fix prev/next links on public profile page (#6497)
* Fix prev/next links on public profile page

* Don't make pagination urls if no available statuses

* Fix empty check method

* Put left chevron before prev page link

* Add scope for pagination "starting at" a given id

* Status pagination try 2:

s/prev/older and s/next/newer
"older" on left, "newer" on right
Use new scope for "newer" link
Extract magic 20 page size to constant
Remove max_id from feed pagination as it's not respected

* Reinstate max_id for accounts atom stream

* normalize
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/paginable.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/concerns/paginable.rb b/app/models/concerns/paginable.rb
index 6061bf9bd..66695677e 100644
--- a/app/models/concerns/paginable.rb
+++ b/app/models/concerns/paginable.rb
@@ -10,5 +10,14 @@ module Paginable
       query = query.where(arel_table[:id].gt(since_id)) if since_id.present?
       query
     }
+
+    # Differs from :paginate_by_max_id in that it gives the results immediately following min_id,
+    # whereas since_id gives the items with largest id, but with since_id as a cutoff.
+    # Results will be in ascending order by id.
+    scope :paginate_by_min_id, ->(limit, min_id = nil) {
+      query = reorder(arel_table[:id]).limit(limit)
+      query = query.where(arel_table[:id].gt(min_id)) if min_id.present?
+      query
+    }
   end
 end