Class: Ci::RunnersFinder

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

Constant Summary collapse

DEFAULT_SORT =
'created_at_desc'

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Methods inherited from UnionFinder

#find_union

Constructor Details

#initialize(current_user:, params:) ⇒ RunnersFinder

Returns a new instance of RunnersFinder.



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

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

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/finders/ci/runners_finder.rb', line 16

def execute
  items = if @project
            project_runners
          elsif @group
            group_runners
          else
            all_runners
          end

  items = search(items)
  items = by_active(items)
  items = by_status(items)
  items = by_upgrade_status(items)
  items = by_runner_type(items)
  items = by_tag_list(items)
  items = by_creator_id(items)
  items = by_creator_username(items)
  items = by_version_prefix(items)
  items = request_tag_list(items)

  sort(items)
end

#sort_keyObject



39
40
41
# File 'app/finders/ci/runners_finder.rb', line 39

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