Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
70dac459
Commit
70dac459
authored
Apr 02, 2020
by
Aakriti Gupta
Committed by
Bob Van Landuyt
Apr 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass params on initializing GroupMemberFinder
parent
fcf2ee20
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
14 deletions
+17
-14
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+1
-1
app/finders/group_members_finder.rb
app/finders/group_members_finder.rb
+6
-3
ee/lib/analytics/group_activity_calculator.rb
ee/lib/analytics/group_activity_calculator.rb
+5
-5
spec/finders/group_members_finder_spec.rb
spec/finders/group_members_finder_spec.rb
+5
-5
No files found.
app/controllers/groups/group_members_controller.rb
View file @
70dac459
...
@@ -57,7 +57,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
...
@@ -57,7 +57,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
def
find_members
def
find_members
filter_params
=
params
.
slice
(
:two_factor
,
:search
).
merge
(
sort:
@sort
)
filter_params
=
params
.
slice
(
:two_factor
,
:search
).
merge
(
sort:
@sort
)
GroupMembersFinder
.
new
(
@group
,
current_user
).
execute
(
include_relations:
requested_relations
,
params:
filter_param
s
)
GroupMembersFinder
.
new
(
@group
,
current_user
,
params:
filter_params
).
execute
(
include_relations:
requested_relation
s
)
end
end
def
can_manage_members
def
can_manage_members
...
...
app/finders/group_members_finder.rb
View file @
70dac459
...
@@ -10,13 +10,16 @@ class GroupMembersFinder < UnionFinder
...
@@ -10,13 +10,16 @@ class GroupMembersFinder < UnionFinder
# created_after: datetime
# created_after: datetime
# created_before: datetime
# created_before: datetime
def
initialize
(
group
,
user
=
nil
)
attr_reader
:params
def
initialize
(
group
,
user
=
nil
,
params:
{})
@group
=
group
@group
=
group
@user
=
user
@user
=
user
@params
=
params
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
include_relations:
[
:inherited
,
:direct
]
,
params:
{}
)
def
execute
(
include_relations:
[
:inherited
,
:direct
])
group_members
=
group
.
members
group_members
=
group
.
members
relations
=
[]
relations
=
[]
@params
=
params
@params
=
params
...
@@ -50,7 +53,7 @@ class GroupMembersFinder < UnionFinder
...
@@ -50,7 +53,7 @@ class GroupMembersFinder < UnionFinder
private
private
attr_reader
:user
,
:group
,
:params
attr_reader
:user
,
:group
def
filter_members
(
members
)
def
filter_members
(
members
)
members
=
members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
members
=
members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
...
...
ee/lib/analytics/group_activity_calculator.rb
View file @
70dac459
...
@@ -21,11 +21,11 @@ module Analytics
...
@@ -21,11 +21,11 @@ module Analytics
def
new_members_count
def
new_members_count
@new_members_count
||=
@new_members_count
||=
GroupMembersFinder
.
new
(
@group
,
@current_user
)
GroupMembersFinder
.
new
(
.
execute
(
@group
,
include_relations:
[
:direct
,
:descendants
]
,
@current_user
,
params:
{
created_after:
DURATION
.
ago
}
params:
{
created_after:
DURATION
.
ago
}
).
count
).
execute
(
include_relations:
[
:direct
,
:descendants
]
).
count
end
end
private
private
...
...
spec/finders/group_members_finder_spec.rb
View file @
70dac459
...
@@ -82,7 +82,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -82,7 +82,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_developer
(
user3
)
group
.
add_developer
(
user3
)
member
=
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
params:
{
search:
user1
.
name
})
result
=
described_class
.
new
(
group
,
params:
{
search:
user1
.
name
}).
execute
expect
(
result
.
to_a
).
to
match_array
([
member
])
expect
(
result
.
to_a
).
to
match_array
([
member
])
end
end
...
@@ -92,7 +92,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -92,7 +92,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_developer
(
user3
)
group
.
add_developer
(
user3
)
group
.
add_maintainer
(
user1
)
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
user1
.
name
}
)
result
=
described_class
.
new
(
group
,
params:
{
search:
user1
.
name
}).
execute
(
include_relations:
[
:inherited
]
)
expect
(
result
.
to_a
).
to
match_array
([])
expect
(
result
.
to_a
).
to
match_array
([])
end
end
...
@@ -103,7 +103,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -103,7 +103,7 @@ describe GroupMembersFinder, '#execute' do
nested_group
.
add_maintainer
(
create
(
:user
,
name:
user1
.
name
))
nested_group
.
add_maintainer
(
create
(
:user
,
name:
user1
.
name
))
member
=
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
nested_group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
member
.
user
.
name
}
)
result
=
described_class
.
new
(
nested_group
,
params:
{
search:
member
.
user
.
name
}).
execute
(
include_relations:
[
:inherited
]
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
end
...
@@ -113,7 +113,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -113,7 +113,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_maintainer
(
user1
)
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user5
)
member
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'enabled'
})
result
=
described_class
.
new
(
group
,
user2
,
params:
{
two_factor:
'enabled'
}).
execute
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
end
...
@@ -123,7 +123,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -123,7 +123,7 @@ describe GroupMembersFinder, '#execute' do
member2
=
group
.
add_maintainer
(
user1
)
member2
=
group
.
add_maintainer
(
user1
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'disabled'
})
result
=
described_class
.
new
(
group
,
user2
,
params:
{
two_factor:
'disabled'
}).
execute
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
])
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment