summaryrefslogtreecommitdiff
path: root/config/initializers/active_record_keyset_pagination.rb
blob: f8c2ada52551d6a84bff3a22835d339ba7c49ffb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# frozen_string_literal: true

module PaginatorExtension
  # This method loads the records for the requested page and returns a keyset paginator object.
  def keyset_paginate(cursor: nil, per_page: 20)
    Gitlab::Pagination::Keyset::Paginator.new(scope: self.dup, cursor: cursor, per_page: per_page)
  end
end

ActiveSupport.on_load(:active_record) do
  ActiveRecord::Relation.include(PaginatorExtension)
end