diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-07 20:43:36 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-07 20:43:36 +0300 |
commit | 0fdf54ddf5894ec1057b7351140fdce4f0df0ed1 (patch) | |
tree | a635d8071bb358771f80173f51b9cd2e5896b64e /app/finders/environments_finder.rb | |
parent | 5dc3b37b86036999fe3dd900fbe0c9270bd40474 (diff) |
Move permission check before more expensive checks
Diffstat (limited to 'app/finders/environments_finder.rb')
-rw-r--r-- | app/finders/environments_finder.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb index 2f1a09fcb55..a59f8c1efa3 100644 --- a/app/finders/environments_finder.rb +++ b/app/finders/environments_finder.rb @@ -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 |