Class: Gitlab::Pagination::GitalyKeysetPager

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/pagination/gitaly_keyset_pager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_context, project) ⇒ GitalyKeysetPager

Returns a new instance of GitalyKeysetPager.


9
10
11
12
# File 'lib/gitlab/pagination/gitaly_keyset_pager.rb', line 9

def initialize(request_context, project)
  @request_context = request_context
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project


6
7
8
# File 'lib/gitlab/pagination/gitaly_keyset_pager.rb', line 6

def project
  @project
end

#request_contextObject (readonly)

Returns the value of attribute request_context


6
7
8
# File 'lib/gitlab/pagination/gitaly_keyset_pager.rb', line 6

def request_context
  @request_context
end

Instance Method Details

#paginate(finder) ⇒ Object

It is expected that the given finder will respond to `execute` method with `gitaly_pagination: true` option and supports pagination via gitaly.


16
17
18
19
20
21
22
23
# File 'lib/gitlab/pagination/gitaly_keyset_pager.rb', line 16

def paginate(finder)
  return paginate_via_gitaly(finder) if keyset_pagination_enabled?

  branches = ::Kaminari.paginate_array(finder.execute)
  Gitlab::Pagination::OffsetPagination
    .new(request_context)
    .paginate(branches)
end