提交 0fdf54dd 编写于 作者: D Douwe Maan

Move permission check before more expensive checks

上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册