diff options
Diffstat (limited to 'app/finders/pipelines_finder.rb')
-rw-r--r-- | app/finders/pipelines_finder.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb index a99a889a7e9..b03d730f975 100644 --- a/app/finders/pipelines_finder.rb +++ b/app/finders/pipelines_finder.rb @@ -10,6 +10,7 @@ class PipelinesFinder @params = params end + # rubocop: disable CodeReuse/ActiveRecord def execute unless Ability.allowed?(current_user, :read_pipeline, project) return Ci::Pipeline.none @@ -25,16 +26,21 @@ class PipelinesFinder items = by_yaml_errors(items) sort_items(items) end + # rubocop: enable CodeReuse/ActiveRecord private + # rubocop: disable CodeReuse/ActiveRecord def ids_for_ref(refs) pipelines.where(ref: refs).group(:ref).select('max(id)') end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def from_ids(ids) pipelines.unscoped.where(id: ids) end + # rubocop: enable CodeReuse/ActiveRecord def branches project.repository.branch_names @@ -61,12 +67,15 @@ class PipelinesFinder end end + # rubocop: disable CodeReuse/ActiveRecord def by_status(items) return items unless HasStatus::AVAILABLE_STATUSES.include?(params[:status]) items.where(status: params[:status]) end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def by_ref(items) if params[:ref].present? items.where(ref: params[:ref]) @@ -74,7 +83,9 @@ class PipelinesFinder items end end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def by_sha(items) if params[:sha].present? items.where(sha: params[:sha]) @@ -82,7 +93,9 @@ class PipelinesFinder items end end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def by_name(items) if params[:name].present? items.joins(:user).where(users: { name: params[:name] }) @@ -90,7 +103,9 @@ class PipelinesFinder items end end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def by_username(items) if params[:username].present? items.joins(:user).where(users: { username: params[:username] }) @@ -98,7 +113,9 @@ class PipelinesFinder items end end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def by_yaml_errors(items) case Gitlab::Utils.to_boolean(params[:yaml_errors]) when true @@ -109,7 +126,9 @@ class PipelinesFinder items end end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def sort_items(items) order_by = if ALLOWED_INDEXED_COLUMNS.include?(params[:order_by]) params[:order_by] @@ -125,4 +144,5 @@ class PipelinesFinder items.order(order_by => sort) end + # rubocop: enable CodeReuse/ActiveRecord end |