Expand FindCommit caching to blob and refs
This enables FindCommit caching to the following actions: * BlobController#show * RefsController#logs_tree It also improves caching in CommitsController since some duplicate requests were occuring inside the before_action definitions.
This commit is contained in:
parent
7a7c131f7b
commit
0d8e9f6ee3
7 changed files with 18 additions and 4 deletions
|
@ -9,6 +9,8 @@ class Projects::BlobController < Projects::ApplicationController
|
|||
include ActionView::Helpers::SanitizeHelper
|
||||
prepend_before_action :authenticate_user!, only: [:edit]
|
||||
|
||||
around_action :allow_gitaly_ref_name_caching, only: [:show]
|
||||
|
||||
before_action :require_non_empty_project, except: [:new, :create]
|
||||
before_action :authorize_download_code!
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class Projects::CommitsController < Projects::ApplicationController
|
|||
include RendersCommits
|
||||
|
||||
prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) }
|
||||
around_action :allow_gitaly_ref_name_caching
|
||||
before_action :whitelist_query_limiting, except: :commits_root
|
||||
before_action :require_non_empty_project
|
||||
before_action :assign_ref_vars, except: :commits_root
|
||||
|
@ -14,8 +15,6 @@ class Projects::CommitsController < Projects::ApplicationController
|
|||
before_action :validate_ref!, except: :commits_root
|
||||
before_action :set_commits, except: :commits_root
|
||||
|
||||
around_action :allow_gitaly_ref_name_caching
|
||||
|
||||
def commits_root
|
||||
redirect_to project_commits_path(@project, @project.default_branch)
|
||||
end
|
||||
|
|
|
@ -4,6 +4,8 @@ class Projects::RefsController < Projects::ApplicationController
|
|||
include ExtractsPath
|
||||
include TreeHelper
|
||||
|
||||
around_action :allow_gitaly_ref_name_caching, only: [:logs_tree]
|
||||
|
||||
before_action :require_non_empty_project
|
||||
before_action :validate_ref_id
|
||||
before_action :assign_ref_vars
|
||||
|
|
|
@ -10,6 +10,8 @@ class ProjectsController < Projects::ApplicationController
|
|||
|
||||
prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) }
|
||||
|
||||
around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
|
||||
|
||||
before_action :whitelist_query_limiting, only: [:create]
|
||||
before_action :authenticate_user!, except: [:index, :show, :activity, :refs, :resolve]
|
||||
before_action :redirect_git_extension, only: [:show]
|
||||
|
@ -26,8 +28,6 @@ class ProjectsController < Projects::ApplicationController
|
|||
before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export, :generate_new_export]
|
||||
before_action :event_filter, only: [:show, :activity]
|
||||
|
||||
around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
|
||||
|
||||
layout :determine_layout
|
||||
|
||||
def index
|
||||
|
|
5
changelogs/unreleased/sh-improve-find-commit-caching.yml
Normal file
5
changelogs/unreleased/sh-improve-find-commit-caching.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Expand FindCommit caching to blob and refs
|
||||
merge_request: 27084
|
||||
author:
|
||||
type: performance
|
|
@ -10,6 +10,8 @@ describe Projects::BlobController do
|
|||
|
||||
context 'with file path' do
|
||||
before do
|
||||
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
|
||||
|
||||
get(:show,
|
||||
params: {
|
||||
namespace_id: project.namespace,
|
||||
|
|
|
@ -44,11 +44,15 @@ describe Projects::RefsController do
|
|||
end
|
||||
|
||||
it 'renders JS' do
|
||||
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
|
||||
|
||||
xhr_get(:js)
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'renders JSON' do
|
||||
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
|
||||
|
||||
xhr_get(:json)
|
||||
|
||||
expect(response).to be_success
|
||||
|
|
Loading…
Reference in a new issue