diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-08-15 08:06:37 +0000 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-08-18 12:06:39 -0500 |
commit | f3da423a2107836fadbff7957679652f289c92ad (patch) | |
tree | 985fae8f41a2af129ef8871e9ca08eb32a3ce096 /app/models/namespace.rb | |
parent | 9af78141d030e70349f24449e2992f555c03cc34 (diff) | |
download | gitlab-ce-f3da423a2107836fadbff7957679652f289c92ad.tar.gz |
Merge branch '34533-speed-up-group-project-authorizations' into 'master'9-5-stable-prepare-RC6
Speed up Group#user_ids_for_project_authorizations
Closes #36182
See merge request !13508
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r-- | app/models/namespace.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 6073fb94a3f..e7bc1d1b080 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -156,6 +156,14 @@ class Namespace < ActiveRecord::Base .base_and_ancestors end + def self_and_ancestors + return self.class.where(id: id) unless parent_id + + Gitlab::GroupHierarchy + .new(self.class.where(id: id)) + .base_and_ancestors + end + # Returns all the descendants of the current namespace. def descendants Gitlab::GroupHierarchy @@ -163,6 +171,12 @@ class Namespace < ActiveRecord::Base .base_and_descendants end + def self_and_descendants + Gitlab::GroupHierarchy + .new(self.class.where(id: id)) + .base_and_descendants + end + def user_ids_for_project_authorizations [owner_id] end |