Commit 0fdf54dd authored by Douwe Maan's avatar Douwe Maan

Move permission check before more expensive checks

parent 5dc3b37b
...@@ -24,6 +24,10 @@ class EnvironmentsFinder ...@@ -24,6 +24,10 @@ class EnvironmentsFinder
environments = project.environments.available environments = project.environments.available
.where(id: environment_ids).order_by_last_deployed_at.to_a .where(id: environment_ids).order_by_last_deployed_at.to_a
environments.select! do |environment|
Ability.allowed?(current_user, :read_environment, environment)
end
if ref && commit if ref && commit
environments.select! do |environment| environments.select! do |environment|
environment.includes_commit?(commit) environment.includes_commit?(commit)
...@@ -36,9 +40,7 @@ class EnvironmentsFinder ...@@ -36,9 +40,7 @@ class EnvironmentsFinder
end end
end end
environments.select do |environment| environments
Ability.allowed?(current_user, :read_environment, environment)
end
end end
private private
......
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