diff options
author | Adam Hegyi <ahegyi@gitlab.com> | 2019-07-02 07:18:21 +0200 |
---|---|---|
committer | Adam Hegyi <ahegyi@gitlab.com> | 2019-07-02 07:35:04 +0200 |
commit | f2bdd31c3eca8065349060f1997bc9cfb99aa0c6 (patch) | |
tree | ef69b703a76a27ae0fb87da02648029ed1f43b64 | |
parent | 055ed2e8e79e917609e27f19e9149885036e503b (diff) | |
download | gitlab-ce-memoize-namespace-root-ancestor.tar.gz |
Memoizing root_ancestor in Namespacememoize-namespace-root-ancestor
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? |