diff options
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 3509299a579..739135e82dd 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -73,6 +73,7 @@ class Group < Namespace has_one :dependency_proxy_setting, class_name: 'DependencyProxy::GroupSetting' has_many :dependency_proxy_blobs, class_name: 'DependencyProxy::Blob' + has_many :dependency_proxy_manifests, class_name: 'DependencyProxy::Manifest' accepts_nested_attributes_for :variables, allow_destroy: true @@ -402,6 +403,13 @@ class Group < Namespace .where(source_id: self_and_hierarchy.reorder(nil).select(:id)) end + def direct_and_indirect_members_with_inactive + GroupMember + .non_request + .non_invite + .where(source_id: self_and_hierarchy.reorder(nil).select(:id)) + end + def users_with_parents User .where(id: members_with_parents.select(:user_id)) @@ -428,6 +436,20 @@ class Group < Namespace ]) end + # Returns all users (also inactive) that are members of the group because: + # 1. They belong to the group + # 2. They belong to a project that belongs to the group + # 3. They belong to a sub-group or project in such sub-group + # 4. They belong to an ancestor group + def direct_and_indirect_users_with_inactive + User.from_union([ + User + .where(id: direct_and_indirect_members_with_inactive.select(:user_id)) + .reorder(nil), + project_users_with_descendants + ]) + end + def users_count members.count end |