summaryrefslogtreecommitdiff
path: root/app/finders/deployments_finder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/deployments_finder.rb')
-rw-r--r--app/finders/deployments_finder.rb20
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