Class: Ci::PipelinesFinder
- Inherits:
-
Object
- Object
- Ci::PipelinesFinder
- Defined in:
- app/finders/ci/pipelines_finder.rb
Constant Summary collapse
- ALLOWED_INDEXED_COLUMNS =
%w[id status ref updated_at user_id].freeze
- ALLOWED_SCOPES =
{ RUNNING: 'running', PENDING: 'pending', FINISHED: 'finished', BRANCHES: 'branches', TAGS: 'tags' }.freeze
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#pipelines ⇒ Object
readonly
Returns the value of attribute pipelines.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, current_user, params = {}) ⇒ PipelinesFinder
constructor
A new instance of PipelinesFinder.
Constructor Details
#initialize(project, current_user, params = {}) ⇒ PipelinesFinder
Returns a new instance of PipelinesFinder.
16 17 18 19 20 21 |
# File 'app/finders/ci/pipelines_finder.rb', line 16 def initialize(project, current_user, params = {}) @project = project @current_user = current_user @pipelines = project.all_pipelines @params = params end |
Instance Attribute Details
#current_user ⇒ Object (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 |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'app/finders/ci/pipelines_finder.rb', line 5 def params @params end |
#pipelines ⇒ Object (readonly)
Returns the value of attribute pipelines.
5 6 7 |
# File 'app/finders/ci/pipelines_finder.rb', line 5 def pipelines @pipelines end |
#project ⇒ Object (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
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/finders/ci/pipelines_finder.rb', line 23 def execute unless Ability.allowed?(current_user, :read_pipeline, project) return Ci::Pipeline.none end items = pipelines items = items.no_child unless params[:iids].present? items = by_iids(items) items = by_scope(items) items = by_status(items) items = by_ref(items) items = by_sha(items) items = by_username(items) items = by_yaml_errors(items) items = by_updated_at(items) items = by_source(items) sort_items(items) end |