diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 00:08:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 00:08:29 +0300 |
commit | 40254b9ace2a74a3c9f1cc51a1b1d5e3e78c1ae9 (patch) | |
tree | 9b735ef933178be36d35088f3acab2d9b75dbbad /app/finders/deployments_finder.rb | |
parent | 22a0d312ae82e7dda3073d5d1a5a766d7641738d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders/deployments_finder.rb')
-rw-r--r-- | app/finders/deployments_finder.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/finders/deployments_finder.rb b/app/finders/deployments_finder.rb index b718b55dd68..0bb8ce6b4da 100644 --- a/app/finders/deployments_finder.rb +++ b/app/finders/deployments_finder.rb @@ -17,6 +17,8 @@ class DeploymentsFinder def execute items = init_collection items = by_updated_at(items) + items = by_environment(items) + items = by_status(items) sort(items) end @@ -58,6 +60,24 @@ class DeploymentsFinder items end + def by_environment(items) + if params[:environment].present? + items.for_environment_name(params[:environment]) + else + items + end + end + + def by_status(items) + return items unless params[:status].present? + + unless Deployment.statuses.key?(params[:status]) + raise ArgumentError, "The deployment status #{params[:status]} is invalid" + end + + items.for_status(params[:status]) + end + def sort_params order_by = ALLOWED_SORT_VALUES.include?(params[:order_by]) ? params[:order_by] : DEFAULT_SORT_VALUE order_direction = ALLOWED_SORT_DIRECTIONS.include?(params[:sort]) ? params[:sort] : DEFAULT_SORT_DIRECTION |