summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-26 16:19:59 -0700
committerStan Hu <stanhu@gmail.com>2019-06-26 16:24:46 -0700
commitee791d3f40913fa57d878aecb9bf8c86ea27e3b4 (patch)
tree495a2b3e9b6f60e8b671567560ee7c3c56775641
parent13d8992006c5212726b843c4dd06d43caab2f7f9 (diff)
downloadgitlab-ce-ee791d3f40913fa57d878aecb9bf8c86ea27e3b4.tar.gz
Enable Gitaly ref caching for SearchControllersh-add-gitaly-ref-caching-search-controller
As we noticed in https://gitlab.com/gitlab-org/gitlab-ce/issues/56627#note_185828742, clicking on the "Issues" tab often requests the same reference in rendering Markdown.
-rw-r--r--app/controllers/application_controller.rb6
-rw-r--r--app/controllers/projects/application_controller.rb6
-rw-r--r--app/controllers/search_controller.rb2
-rw-r--r--changelogs/unreleased/sh-add-gitaly-ref-caching-search-controller.yml5
-rw-r--r--spec/controllers/search_controller_spec.rb4
5 files changed, 17 insertions, 6 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 7321f719deb..75108bf2646 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -516,4 +516,10 @@ class ApplicationController < ActionController::Base
def sentry_context
Gitlab::Sentry.context(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/application_controller.rb b/app/controllers/projects/application_controller.rb
index 80e4f54bbf4..90396c15375 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -87,10 +87,4 @@ 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/search_controller.rb b/app/controllers/search_controller.rb
index a80ab3bcd28..8c674be58c5 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -5,6 +5,8 @@ class SearchController < ApplicationController
include SearchHelper
include RendersCommits
+ around_action :allow_gitaly_ref_name_caching
+
skip_before_action :authenticate_user!
requires_cross_project_access if: -> do
search_term_present = params[:search].present? || params[:term].present?
diff --git a/changelogs/unreleased/sh-add-gitaly-ref-caching-search-controller.yml b/changelogs/unreleased/sh-add-gitaly-ref-caching-search-controller.yml
new file mode 100644
index 00000000000..d4be28e9883
--- /dev/null
+++ b/changelogs/unreleased/sh-add-gitaly-ref-caching-search-controller.yml
@@ -0,0 +1,5 @@
+---
+title: Enable Gitaly ref caching for SearchController
+merge_request: 30105
+author:
+type: performance
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index 4634d1d4bb3..fd36ff812ff 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -17,6 +17,10 @@ describe SearchController do
set(:project) { create(:project, :public, :repository, :wiki_repo) }
+ before do
+ expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
+ end
+
subject { get(:show, params: { project_id: project.id, scope: scope, search: 'merge' }) }
where(:partial, :scope) do