diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-07-02 11:19:47 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-07-02 11:19:47 +0300 |
commit | 6d867cad918d80216908b68dba7e785997871ac7 (patch) | |
tree | 80f561bb14310805f7d2e56424723c2cbd3bd108 | |
parent | ebf289fded498bf928ae979245f4be753865781a (diff) | |
parent | b8563dadc02ecd390c550ba9a76180f65c53c3af (diff) |
Merge branch 'memoize-namespace-root-ancestor' into 'master'
Memoizing root_ancestor in Namespace
See merge request gitlab-org/gitlab-ce!30248
-rw-r--r-- | app/models/namespace.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index f9b53b2b70a..bfa33dc86ac 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -250,7 +250,9 @@ class Namespace < ApplicationRecord end def root_ancestor - self_and_ancestors.reorder(nil).find_by(parent_id: nil) + strong_memoize(:root_ancestor) do + self_and_ancestors.reorder(nil).find_by(parent_id: nil) + end end def subgroup? |