diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-11 15:19:11 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-08-14 12:47:15 +0100 |
commit | d7b03c37f8346e29f21f0196fd3a532effa60ec3 (patch) | |
tree | dae0a75f4dd508f2531788247d8bac88e0484162 /app/models/namespace.rb | |
parent | 455dc74e65e7461c1a51bf3ea6594fe20b9df90c (diff) | |
download | gitlab-ce-d7b03c37f8346e29f21f0196fd3a532effa60ec3.tar.gz |
Speed up Group#user_ids_for_project_authorizations
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 |