diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-10 00:11:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-10 00:11:32 +0300 |
commit | 94539479513935f6a50209194a2836f860960f3a (patch) | |
tree | 167d2075b35e3913f057054929fad0a12b2b9dbe /app/models | |
parent | b3986e06460cc2bff35c1c1e7902579b46c1d4c6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/group.rb | 12 | ||||
-rw-r--r-- | app/models/members/group_member.rb | 10 | ||||
-rw-r--r-- | app/models/members/last_group_owner_assigner.rb | 4 |
3 files changed, 8 insertions, 18 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index f3ce9ebd324..9330ffef156 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -512,15 +512,9 @@ class Group < Namespace members_with_parents(only_active_users: false) end - owners = [] - - members_from_hiearchy.all_owners.each_batch do |relation| - owners += relation.preload(:user).load.reject do |member| - member.user.project_bot? - end - end - - owners + members_from_hiearchy.all_owners.left_outer_joins(:user) + .merge(User.without_project_bot) + .allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/417455") end def ldap_synced? diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index b5a590d646e..52b9c3a80e3 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -62,13 +62,9 @@ class GroupMember < Member return false unless access_level == Gitlab::Access::OWNER return last_owner unless last_owner.nil? - owners = group.member_owners_excluding_project_bots - - owners.reject! do |member| - member.group == group && member.user_id == user_id - end - - owners.empty? + group.member_owners_excluding_project_bots.where.not( + group: group, user_id: user_id + ).empty? end private diff --git a/app/models/members/last_group_owner_assigner.rb b/app/models/members/last_group_owner_assigner.rb index 707cd7bf31c..45cd8d8b000 100644 --- a/app/models/members/last_group_owner_assigner.rb +++ b/app/models/members/last_group_owner_assigner.rb @@ -22,7 +22,7 @@ class LastGroupOwnerAssigner end def owner_ids - @owner_ids ||= member_ids & owners.map(&:id) + @owner_ids ||= owners.where(id: member_ids).ids end def member_ids @@ -30,6 +30,6 @@ class LastGroupOwnerAssigner end def owners - @owners ||= group.member_owners_excluding_project_bots + @owners ||= group.member_owners_excluding_project_bots.load end end |