Commit bbd1be00 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Change project list cache key to use route.cache_key instead of namespace

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 1028e053
...@@ -158,8 +158,7 @@ module ProjectsHelper ...@@ -158,8 +158,7 @@ module ProjectsHelper
def project_list_cache_key(project) def project_list_cache_key(project)
key = [ key = [
'parent/' + project.namespace.parent_full_path, project.route.cache_key,
project.namespace.cache_key,
project.cache_key, project.cache_key,
controller.controller_name, controller.controller_name,
controller.action_name, controller.action_name,
......
...@@ -224,10 +224,6 @@ class Namespace < ActiveRecord::Base ...@@ -224,10 +224,6 @@ class Namespace < ActiveRecord::Base
parent.present? parent.present?
end end
def parent_full_path
full_path.split('/')[0...-1].join('/')
end
private private
def repository_storage_paths def repository_storage_paths
......
...@@ -35,7 +35,7 @@ class Route < ActiveRecord::Base ...@@ -35,7 +35,7 @@ class Route < ActiveRecord::Base
old_path = route.path old_path = route.path
# Callbacks must be run manually # Callbacks must be run manually
route.update_columns(attributes) route.update_columns(attributes.merge(updated_at: Time.now))
# We are not calling route.delete_conflicting_redirects here, in hopes # We are not calling route.delete_conflicting_redirects here, in hopes
# of avoiding deadlocks. The parent (self, in this method) already # of avoiding deadlocks. The parent (self, in this method) already
......
--- ---
title: Add parent full path to project list cache key title: Use route.cache_key for project list cache key
merge_request: 11325 merge_request: 11325
author: author:
...@@ -66,14 +66,8 @@ describe ProjectsHelper do ...@@ -66,14 +66,8 @@ describe ProjectsHelper do
describe "#project_list_cache_key", redis: true do describe "#project_list_cache_key", redis: true do
let(:project) { create(:project) } let(:project) { create(:project) }
it "includes the namespace" do it "includes the route" do
expect(helper.project_list_cache_key(project)).to include(project.namespace.cache_key) expect(helper.project_list_cache_key(project)).to include(project.route.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 end
it "includes the project" do it "includes the project" do
......
...@@ -332,10 +332,4 @@ describe Namespace, models: true do ...@@ -332,10 +332,4 @@ describe Namespace, models: true do
it { expect(group.all_projects.to_a).to eq([project2, project1]) } it { expect(group.all_projects.to_a).to eq([project2, project1]) }
end end
describe '#parent_full_path' do
let(:namespace) { create(:group, :nested) }
it { expect(namespace.parent_full_path).to eq(namespace.parent.path) }
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment