Merge branch 'memoize-namespace-root-ancestor' into 'master'

Memoizing root_ancestor in Namespace

See merge request gitlab-org/gitlab-ce!30248
This commit is contained in:
Thong Kuah 2019-07-02 08:19:47 +00:00
commit 6d867cad91
1 changed files with 3 additions and 1 deletions

View File

@ -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?