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
Tatuya Kamada
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
class
ParticipantsService
<
BaseService
def
execute
(
noteable_type
,
noteable_id
)
@target
=
get_target
(
noteable_type
,
noteable_id
)
participating
=
if
noteable_type
&&
noteable_id
participants_in_target
else
[]
end
@noteable_type
=
noteable_type
@noteable_id
=
noteable_id
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
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
def
target
@target
||=
case
@noteable_type
when
"Issue"
project
.
issues
.
find_by_iid
(
@noteable_id
)
when
"MergeRequest"
project
.
merge_requests
.
find_by_iid
(
@noteable_id
)
when
"Commit"
project
.
commit
(
@noteable_id
)
else
nil
end
end
def
target_owner
return
[]
unless
@target
&&
@
target
.
author
.
present?
return
[]
unless
target
&&
target
.
author
.
present?
[{
name:
@
target
.
author
.
name
,
username:
@
target
.
author
.
username
name:
target
.
author
.
name
,
username:
target
.
author
.
username
}]
end
def
participants_in_target
return
[]
unless
@
target
return
[]
unless
target
users
=
@
target
.
participants
(
current_user
)
users
=
target
.
participants
(
current_user
)
sorted
(
users
)
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