Class: Ci::PipelinesFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/ci/pipelines_finder.rb

Constant Summary collapse

ALLOWED_INDEXED_COLUMNS =
%w[id status ref updated_at user_id].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, current_user, params = {}) ⇒ PipelinesFinder

Returns a new instance of PipelinesFinder.


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

def initialize(project, current_user, params = {})
  @project = project
  @current_user = current_user
  @pipelines = project.all_pipelines
  @params = params
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


5
6
7
# File 'app/finders/ci/pipelines_finder.rb', line 5

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params


5
6
7
# File 'app/finders/ci/pipelines_finder.rb', line 5

def params
  @params
end

#pipelinesObject (readonly)

Returns the value of attribute pipelines


5
6
7
# File 'app/finders/ci/pipelines_finder.rb', line 5

def pipelines
  @pipelines
end

#projectObject (readonly)

Returns the value of attribute project


5
6
7
# File 'app/finders/ci/pipelines_finder.rb', line 5

def project
  @project
end

Instance Method Details

#executeObject


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

def execute
  unless Ability.allowed?(current_user, :read_pipeline, project)
    return Ci::Pipeline.none
  end

  items = pipelines.no_child
  items = by_scope(items)
  items = by_status(items)
  items = by_ref(items)
  items = by_sha(items)
  items = by_name(items)
  items = by_username(items)
  items = by_yaml_errors(items)
  items = by_updated_at(items)
  sort_items(items)
end