Commit c95b88e6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve readability in project model for environments

parent c7350f0c
......@@ -1289,12 +1289,12 @@ class Project < ActiveRecord::Base
end
def environments_for(ref, commit: nil, with_tags: false)
environments_query = with_tags ? 'ref = ? OR tag IS TRUE' : 'ref = ?'
deployments_query = with_tags ? 'ref = ? OR tag IS TRUE' : 'ref = ?'
environment_ids = deployments
.where(deployments_query, ref.to_s)
.group(:environment_id)
.select(:environment_id)
.where(environments_query, ref.to_s)
envs = environments.available.where(id: environment_ids)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment