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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
562c9652
Commit
562c9652
authored
Mar 29, 2016
by
Alfredo Sumaran
Committed by
Jacob Schatz
Apr 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put owner and participating people first
parent
178dfb19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
15 deletions
+24
-15
app/services/projects/participants_service.rb
app/services/projects/participants_service.rb
+24
-15
No files found.
app/services/projects/participants_service.rb
View file @
562c9652
module
Projects
class
ParticipantsService
<
BaseService
def
execute
(
note_type
,
note_id
)
@target
=
get_target
(
note_type
,
note_id
)
participating
=
if
note_type
&&
note_id
participants_in
(
note_type
,
note_id
)
...
...
@@ -8,35 +9,43 @@ module Projects
[]
end
project_members
=
sorted
(
project
.
team
.
members
)
participants
=
all_members
+
groups
+
project_members
+
participating
participants
=
target_owner
+
participating
+
all_members
+
groups
+
project_members
participants
.
uniq
end
def
get_target
(
type
,
id
)
case
type
when
"Issue"
project
.
issues
.
find_by_iid
(
id
)
when
"MergeRequest"
project
.
merge_requests
.
find_by_iid
(
id
)
when
"Commit"
project
.
commit
(
id
)
end
end
def
target_owner
[{
name:
@target
.
author
.
name
,
username:
@target
.
author
.
username
}]
end
def
participants_in
(
type
,
id
)
target
=
case
type
when
"Issue"
project
.
issues
.
find_by_iid
(
id
)
when
"MergeRequest"
project
.
merge_requests
.
find_by_iid
(
id
)
when
"Commit"
project
.
commit
(
id
)
end
return
[]
unless
target
return
[]
unless
@target
users
=
target
.
participants
(
current_user
)
users
=
@
target
.
participants
(
current_user
)
sorted
(
users
)
end
def
sorted
(
users
)
users
.
uniq
.
to_a
.
compact
.
sort_by
(
&
:username
).
map
do
|
user
|
users
.
uniq
.
to_a
.
compact
.
sort_by
(
&
:username
).
map
do
|
user
|
{
username:
user
.
username
,
name:
user
.
name
}
end
end
def
groups
current_user
.
authorized_groups
.
sort_by
(
&
:path
).
map
do
|
group
|
current_user
.
authorized_groups
.
sort_by
(
&
:path
).
map
do
|
group
|
count
=
group
.
users
.
count
{
username:
group
.
path
,
name:
group
.
name
,
count:
count
}
end
...
...
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