Welcome to mirror list, hosted at ThFree Co, Russian Federation.

keyset.rb « pagination « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5bd45fa9b56d7c2dc77b33d23dc453d48320ee7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Gitlab
  module Pagination
    module Keyset
      def self.paginate(request_context, relation)
        Gitlab::Pagination::Keyset::Pager.new(request_context).paginate(relation)
      end

      def self.available?(request_context, relation)
        order_by = request_context.page.order_by

        # This is only available for Project and order-by id (asc/desc)
        return false unless relation.klass == Project
        return false unless order_by.size == 1 && order_by[:id]

        true
      end
    end
  end
end