diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-08 21:08:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-08 21:08:30 +0300 |
commit | 54943f1e68bd4e1951bf3d6c438acab8d783fc31 (patch) | |
tree | 7528e59c2fd305422f64c44c124ed2cda35b6cd2 /app/models/group.rb | |
parent | 8a7e48133fa53ea53107eafb4e71fbe72545588e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 4682e1c378b..5cd80418a14 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -20,6 +20,7 @@ class Group < Namespace include BulkUsersByEmailLoad include ChronicDurationAttribute include RunnerTokenExpirationInterval + include Todoable extend ::Gitlab::Utils::Override @@ -165,7 +166,16 @@ class Group < Namespace scope :by_id, ->(groups) { where(id: groups) } - scope :by_ids_or_paths, -> (ids, paths) { by_id(ids).or(where(path: paths)) } + scope :by_ids_or_paths, -> (ids, paths) do + return by_id(ids) unless paths.present? + + ids_by_full_path = Route + .for_routable_type(Namespace.name) + .where('LOWER(routes.path) IN (?)', paths.map(&:downcase)) + .select(:namespace_id) + + Group.from_union([by_id(ids), by_id(ids_by_full_path), where('LOWER(path) IN (?)', paths.map(&:downcase))]) + end scope :for_authorized_group_members, -> (user_ids) do joins(:group_members) |