Add parent full path to project list cache key

Signed-off-by: NDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
上级 f938f944
......@@ -157,7 +157,16 @@ module ProjectsHelper
end
def project_list_cache_key(project)
key = [project.namespace.cache_key, project.cache_key, controller.controller_name, controller.action_name, current_application_settings.cache_key, 'v2.4']
key = [
'parent/' + project.namespace.parent_full_path,
project.namespace.cache_key,
project.cache_key,
controller.controller_name,
controller.action_name,
current_application_settings.cache_key,
'v2.4'
]
key << pipeline_status_cache_key(project.pipeline_status) if project.pipeline_status.has_status?
key
......
......@@ -224,6 +224,10 @@ class Namespace < ActiveRecord::Base
parent.present?
end
def parent_full_path
full_path.split('/')[0...-1].join('/')
end
private
def repository_storage_paths
......
---
title: Add parent full path to project list cache key
merge_request: 11325
author:
......@@ -70,6 +70,12 @@ describe ProjectsHelper do
expect(helper.project_list_cache_key(project)).to include(project.namespace.cache_key)
end
it "includes the parent namespace in case of subgroup" do
project = create(:project, group: create(:group, :nested))
expect(helper.project_list_cache_key(project)).to include("parent/#{project.namespace.parent.path}")
end
it "includes the project" do
expect(helper.project_list_cache_key(project)).to include(project.cache_key)
end
......
......@@ -332,4 +332,10 @@ describe Namespace, models: true do
it { expect(group.all_projects.to_a).to eq([project2, project1]) }
end
describe '#parent_full_path' do
let(:namespace) { create(:group, :nested) }
it { expect(namespace.parent_full_path).to eq(namespace.parent.path) }
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册