Commit 562c9652 authored by Alfredo Sumaran's avatar Alfredo Sumaran Committed by Jacob Schatz

Put owner and participating people first

parent 178dfb19
module Projects module Projects
class ParticipantsService < BaseService class ParticipantsService < BaseService
def execute(note_type, note_id) def execute(note_type, note_id)
@target = get_target(note_type, note_id)
participating = participating =
if note_type && note_id if note_type && note_id
participants_in(note_type, note_id) participants_in(note_type, note_id)
...@@ -8,12 +9,11 @@ module Projects ...@@ -8,12 +9,11 @@ module Projects
[] []
end end
project_members = sorted(project.team.members) project_members = sorted(project.team.members)
participants = all_members + groups + project_members + participating participants = target_owner + participating + all_members + groups + project_members
participants.uniq participants.uniq
end end
def participants_in(type, id) def get_target(type, id)
target =
case type case type
when "Issue" when "Issue"
project.issues.find_by_iid(id) project.issues.find_by_iid(id)
...@@ -22,10 +22,19 @@ module Projects ...@@ -22,10 +22,19 @@ module Projects
when "Commit" when "Commit"
project.commit(id) project.commit(id)
end end
end
return [] unless target def target_owner
[{
name: @target.author.name,
username: @target.author.username
}]
end
def participants_in(type, id)
return [] unless @target
users = target.participants(current_user) users = @target.participants(current_user)
sorted(users) sorted(users)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment