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
a96dc944
Commit
a96dc944
authored
Apr 08, 2016
by
Alfredo Sumaran
Committed by
Jacob Schatz
Apr 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memoize target
parent
1eeabdc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
+20
-22
app/services/projects/participants_service.rb
app/services/projects/participants_service.rb
+20
-22
No files found.
app/services/projects/participants_service.rb
View file @
a96dc944
module
Projects
module
Projects
class
ParticipantsService
<
BaseService
class
ParticipantsService
<
BaseService
def
execute
(
noteable_type
,
noteable_id
)
def
execute
(
noteable_type
,
noteable_id
)
@target
=
get_target
(
noteable_type
,
noteable_id
)
@noteable_type
=
noteable_type
participating
=
@noteable_id
=
noteable_id
if
noteable_type
&&
noteable_id
participants_in_target
else
[]
end
project_members
=
sorted
(
project
.
team
.
members
)
project_members
=
sorted
(
project
.
team
.
members
)
participants
=
target_owner
+
participa
ting
+
all_members
+
groups
+
project_members
participants
=
target_owner
+
participa
nts_in_target
+
all_members
+
groups
+
project_members
participants
.
uniq
participants
.
uniq
end
end
def
get_target
(
type
,
id
)
def
target
case
type
@target
||=
when
"Issue"
case
@noteable_type
project
.
issues
.
find_by_iid
(
id
)
when
"Issue"
when
"MergeRequest"
project
.
issues
.
find_by_iid
(
@noteable_id
)
project
.
merge_requests
.
find_by_iid
(
id
)
when
"MergeRequest"
when
"Commit"
project
.
merge_requests
.
find_by_iid
(
@noteable_id
)
project
.
commit
(
id
)
when
"Commit"
end
project
.
commit
(
@noteable_id
)
else
nil
end
end
end
def
target_owner
def
target_owner
return
[]
unless
@target
&&
@
target
.
author
.
present?
return
[]
unless
target
&&
target
.
author
.
present?
[{
[{
name:
@
target
.
author
.
name
,
name:
target
.
author
.
name
,
username:
@
target
.
author
.
username
username:
target
.
author
.
username
}]
}]
end
end
def
participants_in_target
def
participants_in_target
return
[]
unless
@
target
return
[]
unless
target
users
=
@
target
.
participants
(
current_user
)
users
=
target
.
participants
(
current_user
)
sorted
(
users
)
sorted
(
users
)
end
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