Commit c7350f0c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Select recently updated environments for auto-close

parent 54c2e234
......@@ -37,6 +37,10 @@ class Environment < ActiveRecord::Base
state :stopped
end
def recently_updated_on?(ref)
ref.to_s == last_deployment.ref
end
def last_deployment
deployments.last
end
......
......@@ -1299,9 +1299,9 @@ class Project < ActiveRecord::Base
envs = environments.available.where(id: environment_ids)
if commit
envs.select { |env| env.includes_commit?(commit) }
envs.select { |environment| env.includes_commit?(commit) }
else
envs.to_a
envs.select { |environment| env.recently_updated_on?(ref) }
end
end
......
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