Class: Ci::RunnersFinder

Inherits:
UnionFinder show all
Includes:
Gitlab::Allowable
Defined in:
app/finders/ci/runners_finder.rb

Constant Summary collapse

ALLOWED_SORTS =
%w[contacted_asc contacted_desc created_at_asc created_at_desc created_date token_expires_at_asc token_expires_at_desc].freeze
DEFAULT_SORT =
'created_at_desc'

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Methods inherited from UnionFinder

#find_union

Constructor Details

#initialize(current_user:, params:) ⇒ RunnersFinder

Returns a new instance of RunnersFinder.


10
11
12
13
14
# File 'app/finders/ci/runners_finder.rb', line 10

def initialize(current_user:, params:)
  @params = params
  @group = params.delete(:group)
  @current_user = current_user
end

Instance Method Details

#executeObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/finders/ci/runners_finder.rb', line 16

def execute
  search!
  filter_by_active!
  filter_by_status!
  filter_by_runner_type!
  filter_by_tag_list!
  sort!
  request_tag_list!

  @runners

rescue Gitlab::Access::AccessDeniedError
  Ci::Runner.none
end

#sort_keyObject


31
32
33
# File 'app/finders/ci/runners_finder.rb', line 31

def sort_key
  ALLOWED_SORTS.include?(@params[:sort]) ? @params[:sort] : DEFAULT_SORT
end