Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-08-11 17:19:11 +0300
committerNick Thomas <nick@gitlab.com>2017-08-14 14:47:15 +0300
commitd7b03c37f8346e29f21f0196fd3a532effa60ec3 (patch)
treedae0a75f4dd508f2531788247d8bac88e0484162 /app/models/namespace.rb
parent455dc74e65e7461c1a51bf3ea6594fe20b9df90c (diff)
Speed up Group#user_ids_for_project_authorizations
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb14
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