BigW Consortium Gitlab

Commit 0fdf54dd by Douwe Maan

Move permission check before more expensive checks

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