about summary refs log tree commit diff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-10-01 12:43:20 +0200
committerThibaut Girka <thib@sitedethib.com>2018-10-01 12:43:20 +0200
commitc91d9b7389c489980fe98812a8f3884b2d41e19e (patch)
tree78509567984a32411c661167e254c8645eba2919 /app/models/concerns
parent4e60a0d5433f5dfa4f71a452cc5c6ceb0f21ceab (diff)
parent5d5d1b528eda560191b2813714c9e461fda3c9d8 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
	app/lib/user_settings_decorator.rb
	app/models/user.rb
	app/serializers/initial_state_serializer.rb
	app/views/stream_entries/_simple_status.html.haml
	config/locales/simple_form.en.yml
	config/locales/simple_form.ja.yml
	config/locales/simple_form.pl.yml
	config/routes.rb
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/paginable.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/concerns/paginable.rb b/app/models/concerns/paginable.rb
index 66695677e..8863094f7 100644
--- a/app/models/concerns/paginable.rb
+++ b/app/models/concerns/paginable.rb
@@ -19,5 +19,13 @@ module Paginable
       query = query.where(arel_table[:id].gt(min_id)) if min_id.present?
       query
     }
+
+    scope :paginate_by_id, ->(limit, options = {}) {
+      if options[:min_id].present?
+        paginate_by_min_id(limit, options[:min_id]).reverse
+      else
+        paginate_by_max_id(limit, options[:max_id], options[:since_id])
+      end
+    }
   end
 end