Class: DeploymentsFinder

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

Overview

WARNING: This finder does not check permissions!

Arguments:

params:
  project: Project model - Find deployments for this project
  updated_after: DateTime
  updated_before: DateTime
  finished_after: DateTime
  finished_before: DateTime
  environment: String
  status: String (see Deployment.statuses)
  order_by: String (see ALLOWED_SORT_VALUES constant)
  sort: String (asc | desc)

Constant Summary collapse

ALLOWED_SORT_VALUES =

Warning: These const are directly used in Deployment Rest API, thus modifying these values could implicity change the API interface or introduce a breaking change. Also, if you add a sort value, make sure that the new query will stay performant with the other filtering/sorting parameters. The composed query could be significantly slower when the filtering and sorting columns are different. See gitlab.com/gitlab-org/gitlab/-/issues/325627 for example.

%w[id iid created_at updated_at ref finished_at].freeze
DEFAULT_SORT_VALUE =
'id'
ALLOWED_SORT_DIRECTIONS =
%w[asc desc].freeze
DEFAULT_SORT_DIRECTION =
'asc'
InefficientQueryError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ DeploymentsFinder

Returns a new instance of DeploymentsFinder.


34
35
36
37
38
# File 'app/finders/deployments_finder.rb', line 34

def initialize(params = {})
  @params = params

  validate!
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.


17
18
19
# File 'app/finders/deployments_finder.rb', line 17

def params
  @params
end

Instance Method Details

#executeObject


40
41
42
43
44
45
46
47
48
# File 'app/finders/deployments_finder.rb', line 40

def execute
  items = init_collection
  items = by_updated_at(items)
  items = by_finished_at(items)
  items = by_environment(items)
  items = by_status(items)
  items = preload_associations(items)
  sort(items)
end