Move permission check before more expensive checks
This commit is contained in:
parent
5dc3b37b86
commit
0fdf54ddf5
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
environments.select do |environment|
|
environments
|
||||||
Ability.allowed?(current_user, :read_environment, environment)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue