summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-02-08 17:02:25 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-02-10 17:34:12 +0200
commit5f85487c1526f2921f1cef30aceb2fddf84d3632 (patch)
treefd2eeccef302f6ec04f85d1620cdfc8e4edf3c5e /app/finders
parent059d1ae4c847aa9018c89900b39c2782aa9b623e (diff)
downloadgitlab-ce-5f85487c1526f2921f1cef30aceb2fddf84d3632.tar.gz
Show parent group members for nested groupdz-nested-groups-members-page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/group_members_finder.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb
new file mode 100644
index 00000000000..9f2206346ce
--- /dev/null
+++ b/app/finders/group_members_finder.rb
@@ -0,0 +1,20 @@
+class GroupMembersFinder < Projects::ApplicationController
+ def initialize(group)
+ @group = group
+ end
+
+ def execute
+ group_members = @group.members
+
+ return group_members unless @group.parent
+
+ parents_members = GroupMember.non_request.
+ where(source_id: @group.ancestors.select(:id)).
+ where.not(user_id: @group.users.select(:id))
+
+ wheres = ["members.id IN (#{group_members.select(:id).to_sql})"]
+ wheres << "members.id IN (#{parents_members.select(:id).to_sql})"
+
+ GroupMember.where(wheres.join(' OR '))
+ end
+end