summaryrefslogtreecommitdiff
path: root/lib/gitlab/pagination/keyset.rb
blob: 67a5530d46c51ba3862c596a8c452bcfb38e0a61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module Gitlab
  module Pagination
    module Keyset
      SUPPORTED_TYPES = [
        Project
      ].freeze

      def self.available_for_type?(relation)
        SUPPORTED_TYPES.include?(relation.klass)
      end

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

        return false unless available_for_type?(relation)
        return false unless order_by.size == 1 && order_by[:id]

        true
      end
    end
  end
end