diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-06-28 12:54:02 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-06-28 15:25:15 +0300 |
commit | dd467d6c758b485938553f312ee276fd54e63384 (patch) | |
tree | 34effd399f67a8507343586b175286d7d545067e /app/controllers | |
parent | 50a11a339e65b23bd33e5ad937dbc39674093869 (diff) |
Prevents project first environment from being fetched in every project view
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/application_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 13 | ||||
-rw-r--r-- | app/controllers/projects/git_http_client_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/projects/uploads_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 1 |
5 files changed, 14 insertions, 8 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 5475e333db9..5ab6d103c89 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -5,7 +5,6 @@ class Projects::ApplicationController < ApplicationController skip_before_action :authenticate_user! before_action :project before_action :repository - before_action :available_environment layout 'project' helper_method :repository, :can_collaborate_with_project?, :user_access @@ -33,10 +32,6 @@ class Projects::ApplicationController < ApplicationController @repository ||= project.repository end - def available_environment - @available_environment ||= project.environments.with_state(:available).first - end - def authorize_action!(action) unless can?(current_user, action, project) return access_denied! diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index decef19a0a2..53da384dc74 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -124,6 +124,19 @@ class Projects::EnvironmentsController < Projects::ApplicationController render :empty end + def metrics_redirect + environment = project.environments.with_state(:available).first + + path = + if environment + environment_metrics_path(environment) + else + empty_project_environments_path(project) + end + + redirect_to path + end + def metrics # Currently, this acts as a hint to load the metrics details into the cache # if they aren't there already diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index 199a8a4c4c5..07249fe3182 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -15,7 +15,6 @@ class Projects::GitHttpClientController < Projects::ApplicationController # Git clients will not know what authenticity token to send along skip_before_action :verify_authenticity_token skip_before_action :repository - skip_before_action :available_environment before_action :authenticate_user private diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index 14e84f6a65f..f5cf089ad98 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -2,7 +2,7 @@ class Projects::UploadsController < Projects::ApplicationController include UploadsActions # These will kick you out if you don't have access. - skip_before_action :project, :repository, :available_environment, + skip_before_action :project, :repository, if: -> { action_name == 'show' && image_or_video? } before_action :authorize_upload_file!, only: [:create] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5a6ccd629d1..c2492a137fb 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,7 +8,6 @@ class ProjectsController < Projects::ApplicationController before_action :redirect_git_extension, only: [:show] before_action :project, except: [:index, :new, :create] before_action :repository, except: [:index, :new, :create] - before_action :available_environment, except: [:index, :new, :create] before_action :assign_ref_vars, only: [:show], if: :repo_exists? before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?] before_action :lfs_blob_ids, only: [:show], if: [:repo_exists?, :project_view_files?] |