diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-26 19:27:27 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-26 19:27:27 +0300 |
commit | 4586d77c85647063675108b0dcdcfebed0c890ca (patch) | |
tree | 382e3d9b36243bd0da2a1c59303b2851adebe68a /app/finders | |
parent | 779169d337394be7cf2b76d01b42550d7a60b488 (diff) | |
parent | 2466a51407205cc16f19c2d055ca21032675e1da (diff) |
Merge branch 'feature/runner-type-filter-for-admin-view' into 'master'
Feature: Runner type filter for admin view
See merge request gitlab-org/gitlab-ce!19649
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/admin/runners_finder.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/app/finders/admin/runners_finder.rb b/app/finders/admin/runners_finder.rb index 3c2d7ee7d76..fbb1cfc5c66 100644 --- a/app/finders/admin/runners_finder.rb +++ b/app/finders/admin/runners_finder.rb @@ -10,6 +10,7 @@ class Admin::RunnersFinder < UnionFinder def execute search! filter_by_status! + filter_by_runner_type! sort! paginate! @@ -36,10 +37,11 @@ class Admin::RunnersFinder < UnionFinder end def filter_by_status! - status = @params[:status_status] - if status.present? && Ci::Runner::AVAILABLE_STATUSES.include?(status) - @runners = @runners.public_send(status) # rubocop:disable GitlabSecurity/PublicSend - end + filter_by!(:status_status, Ci::Runner::AVAILABLE_STATUSES) + end + + def filter_by_runner_type! + filter_by!(:type_type, Ci::Runner::AVAILABLE_TYPES) end def sort! @@ -49,4 +51,12 @@ class Admin::RunnersFinder < UnionFinder def paginate! @runners = @runners.page(@params[:page]).per(NUMBER_OF_RUNNERS_PER_PAGE) end + + def filter_by!(scope_name, available_scopes) + scope = @params[scope_name] + + if scope.present? && available_scopes.include?(scope) + @runners = @runners.public_send(scope) # rubocop:disable GitlabSecurity/PublicSend + end + end end |