Class: Projects::RefsByPaginationService
- Inherits:
-
Object
- Object
- Projects::RefsByPaginationService
- Includes:
- Gitlab::Routing
- Defined in:
- app/services/projects/refs_by_pagination_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(protected_ref, project, params = {}) ⇒ RefsByPaginationService
constructor
A new instance of RefsByPaginationService.
Methods included from Gitlab::Routing
includes_helpers, redirect_legacy_paths, url_helpers
Constructor Details
#initialize(protected_ref, project, params = {}) ⇒ RefsByPaginationService
Returns a new instance of RefsByPaginationService.
9 10 11 12 13 |
# File 'app/services/projects/refs_by_pagination_service.rb', line 9 def initialize(protected_ref, project, params = {}) @protected_ref = protected_ref @project = project @params = params end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/projects/refs_by_pagination_service.rb', line 15 def execute per_page = params[:per_page] || Kaminari.config.default_per_page refs = Gitlab::Git::Finders::RefsFinder.new( project.repository.raw_repository, ref_type: ref_type, search: protected_ref.name, per_page: per_page + 1, page_token: params[:page_token] ).execute last_page = refs.size <= per_page refs = refs.take(per_page) # rubocop:disable CodeReuse/ActiveRecord -- There is no ActiveRecord model for raw Gitaly references refs_with_links(refs, last_page: last_page) end |