Class: Projects::BranchesByModeService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Routing
Defined in:
app/services/projects/branches_by_mode_service.rb

Overview

Projects::BranchesByModeService uses Gitaly page-token pagination in order to optimally fetch branches. The drawback of the page-token pagination is that it doesn’t provide an option of going to the previous page of the collection. That’s why we need to fall back to offset pagination when previous page is requested.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Routing

includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

#initialize(project, params = {}) ⇒ BranchesByModeService

Returns a new instance of BranchesByModeService.



14
15
16
17
# File 'app/services/projects/branches_by_mode_service.rb', line 14

def initialize(project, params = {})
  @project = project
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



12
13
14
# File 'app/services/projects/branches_by_mode_service.rb', line 12

def params
  @params
end

#projectObject (readonly)

Returns the value of attribute project.



12
13
14
# File 'app/services/projects/branches_by_mode_service.rb', line 12

def project
  @project
end

Instance Method Details

#executeObject



19
20
21
22
23
# File 'app/services/projects/branches_by_mode_service.rb', line 19

def execute
  return fetch_branches_via_gitaly_pagination if use_gitaly_pagination?

  fetch_branches_via_offset_pagination
end