diff options
author | Adam Hegyi <ahegyi@gitlab.com> | 2019-07-02 08:19:46 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-07-02 08:19:46 +0000 |
commit | b8563dadc02ecd390c550ba9a76180f65c53c3af (patch) | |
tree | 80f561bb14310805f7d2e56424723c2cbd3bd108 | |
parent | ebf289fded498bf928ae979245f4be753865781a (diff) | |
download | gitlab-ce-b8563dadc02ecd390c550ba9a76180f65c53c3af.tar.gz |
Memoizing root_ancestor in Namespace
The root_ancestor method is heavily used in EE for the group_saml
feature. Having this memoization implemented in CE would eliminate
the need of overriding the root_ancestor method in EE.
-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? |