diff options
-rw-r--r-- | app/helpers/projects_helper.rb | 10 | ||||
-rw-r--r-- | app/models/route.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/dz-project-list-cache-key.yml | 4 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 4 |
4 files changed, 16 insertions, 4 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 78b54dc20e5..98bbcfaaba5 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -157,7 +157,15 @@ 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 = [ + project.route.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 diff --git a/app/models/route.rb b/app/models/route.rb index 12a7fa3d01b..be77b8b51a5 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -35,7 +35,7 @@ class Route < ActiveRecord::Base old_path = route.path # 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 # of avoiding deadlocks. The parent (self, in this method) already diff --git a/changelogs/unreleased/dz-project-list-cache-key.yml b/changelogs/unreleased/dz-project-list-cache-key.yml new file mode 100644 index 00000000000..9e4826e686a --- /dev/null +++ b/changelogs/unreleased/dz-project-list-cache-key.yml @@ -0,0 +1,4 @@ +--- +title: Use route.cache_key for project list cache key +merge_request: 11325 +author: diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index be97973c693..54c5ba57bdf 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -66,8 +66,8 @@ describe ProjectsHelper do describe "#project_list_cache_key", redis: true do let(:project) { create(:project) } - it "includes the namespace" do - expect(helper.project_list_cache_key(project)).to include(project.namespace.cache_key) + it "includes the route" do + expect(helper.project_list_cache_key(project)).to include(project.route.cache_key) end it "includes the project" do |