diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-04-05 01:13:44 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-04-05 01:13:44 +0300 |
commit | 9667ae2e97e0be26888514661e2ad947c1c6ea72 (patch) | |
tree | a1e8f83bb74c999c55ca94e5fa59e6c7a2eeed6b /app | |
parent | 4dda2b2bfcd32f4f7e0065773b2244d5dfab5561 (diff) | |
parent | f2fa7c32992db5a2b1b6acadc6c203c93c139f3b (diff) |
Merge branch 'sh-fix-ref-name-caching' into 'master'
Fix and expand Gitaly FindCommit caching
See merge request gitlab-org/gitlab-ce!27018
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/application_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/pipelines_controller.rb | 12 |
3 files changed, 15 insertions, 9 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 6504fd6c08a..781eac7f080 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -88,4 +88,10 @@ class Projects::ApplicationController < ApplicationController def check_issues_available! return render_404 unless @project.feature_available?(:issues, current_user) end + + def allow_gitaly_ref_name_caching + ::Gitlab::GitalyClient.allow_ref_name_caching do + yield + end + end end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 34cb0416965..39ba2a651d4 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -16,6 +16,8 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo before_action :authenticate_user!, only: [:assign_related_issues] before_action :check_user_can_push_to_source_branch!, only: [:rebase] + around_action :allow_gitaly_ref_name_caching, only: [:index, :show] + def index @merge_requests = @issuables @@ -315,9 +317,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo end def serializer - ::Gitlab::GitalyClient.allow_ref_name_caching do - MergeRequestSerializer.new(current_user: current_user, project: merge_request.project) - end + MergeRequestSerializer.new(current_user: current_user, project: merge_request.project) end def define_edit_vars diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index c306ba3ffcf..22c4b8eef1f 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -8,6 +8,8 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :authorize_create_pipeline!, only: [:new, :create] before_action :authorize_update_pipeline!, only: [:retry, :cancel] + around_action :allow_gitaly_ref_name_caching, only: [:index, :show] + wrap_parameters Ci::Pipeline POLLING_INTERVAL = 10_000 @@ -148,12 +150,10 @@ class Projects::PipelinesController < Projects::ApplicationController private def serialize_pipelines - ::Gitlab::GitalyClient.allow_ref_name_caching do - PipelineSerializer - .new(project: @project, current_user: @current_user) - .with_pagination(request, response) - .represent(@pipelines, disable_coverage: true, preload: true) - end + PipelineSerializer + .new(project: @project, current_user: @current_user) + .with_pagination(request, response) + .represent(@pipelines, disable_coverage: true, preload: true) end def render_show |