diff options
Diffstat (limited to 'app/finders/environments/environments_by_deployments_finder.rb')
-rw-r--r-- | app/finders/environments/environments_by_deployments_finder.rb | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/app/finders/environments/environments_by_deployments_finder.rb b/app/finders/environments/environments_by_deployments_finder.rb index a41cfcb37e4..2716c80ea6e 100644 --- a/app/finders/environments/environments_by_deployments_finder.rb +++ b/app/finders/environments/environments_by_deployments_finder.rb @@ -12,29 +12,18 @@ module Environments # rubocop: disable CodeReuse/ActiveRecord def execute - deployments = project.deployments deployments = if ref deployments_query = params[:with_tags] ? 'ref = :ref OR tag IS TRUE' : 'ref = :ref' - deployments.where(deployments_query, ref: ref.to_s) + Deployment.where(deployments_query, ref: ref.to_s) elsif commit - deployments.where(sha: commit.sha) + Deployment.where(sha: commit.sha) else - deployments.none + Deployment.none end - environments = - if Feature.enabled?(:environments_by_deployments_finder_exists_optimization, default_enabled: :yaml) - project.environments.available - .where('EXISTS (?)', deployments.where('environment_id = environments.id')) - else - environment_ids = deployments - .group(:environment_id) - .select(:environment_id) - - project.environments.available - .where(id: environment_ids) - end + environments = project.environments.available + .where('EXISTS (?)', deployments.where('environment_id = environments.id')) if params[:find_latest] find_one(environments.order_by_last_deployed_at_desc) |