diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-12-05 11:49:45 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-12-05 11:49:45 +0000 |
commit | 04a882d8d3bd68bee71f5b7073cb7a8ce0149852 (patch) | |
tree | 8ddfe60685a89589760d5acdef9fbb0d246e228c /app | |
parent | 4258bfcb4d3216c264fe8f3f53898a4eb70ac225 (diff) | |
parent | 3d4ba90c5007cca3e8619afe8f40675962a9bc73 (diff) | |
download | gitlab-ce-04a882d8d3bd68bee71f5b7073cb7a8ce0149852.tar.gz |
Merge branch 'bvl-limit-fork-queries-on-project-show' into 'master'
Cache the forks in a namespace in the RequestStore
Closes #40625
See merge request gitlab-org/gitlab-ce!15663
Diffstat (limited to 'app')
-rw-r--r-- | app/models/namespace.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index fa76729a702..901dbf2ba69 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -139,7 +139,17 @@ class Namespace < ActiveRecord::Base def find_fork_of(project) return nil unless project.fork_network - project.fork_network.find_forks_in(projects).first + if RequestStore.active? + forks_in_namespace = RequestStore.fetch("namespaces:#{id}:forked_projects") do + Hash.new do |found_forks, project| + found_forks[project] = project.fork_network.find_forks_in(projects).first + end + end + + forks_in_namespace[project] + else + project.fork_network.find_forks_in(projects).first + end end def lfs_enabled? |