2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Repositories
|
|
|
|
class BranchNamesFinder
|
|
|
|
attr_reader :repository, :params
|
|
|
|
|
|
|
|
def initialize(repository, params = {})
|
|
|
|
@repository = repository
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2021-06-08 01:23:25 +05:30
|
|
|
return unless search && offset && limit
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
repository.search_branch_names(search).lazy.drop(offset).take(limit) # rubocop:disable CodeReuse/ActiveRecord
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def search
|
|
|
|
@params[:search].presence
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
def offset
|
|
|
|
@params[:offset]
|
|
|
|
end
|
|
|
|
|
|
|
|
def limit
|
|
|
|
@params[:limit]
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|