summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2018-12-03 10:22:33 +1300
committerThong Kuah <tkuah@gitlab.com>2018-12-05 10:16:44 +1300
commitf85440e63c2eba453e09a5599f0d3e0491a037f1 (patch)
tree0548088994807a52b2a81c87964ffdee835687e1 /app/models/namespace.rb
parentd54791e0942ae774876db22675cde1b54f35109d (diff)
downloadgitlab-ce-f85440e63c2eba453e09a5599f0d3e0491a037f1.tar.gz
Various improvements to hierarchy sorting
- Rename ordered_group_clusters_for_project -> ancestor_clusters_for_clusterable - Improve name of order option. It makes much more sense to have `hierarchy_order: :asc` and `hierarchy_order: :desc` - Allow ancestor_clusters_for_clusterable for group - Re-use code already present in Project
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 11b03846f0b..c38310ed62b 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -192,9 +192,9 @@ class Namespace < ActiveRecord::Base
# returns all ancestors upto but excluding the given namespace
# when no namespace is given, all ancestors upto the top are returned
- def ancestors_upto(top = nil)
+ def ancestors_upto(top = nil, hierarchy_order: nil)
Gitlab::GroupHierarchy.new(self.class.where(id: id))
- .ancestors(upto: top)
+ .ancestors(upto: top, hierarchy_order: hierarchy_order)
end
def self_and_ancestors