gitlab-org--gitlab-foss/app/services/projects/participants_service.rb
Nur Rony eaef94533d shows user avatar in mention autocomplete in editor
adds entry in CHANGELOG

no uninitialized variable and unnecessary if statement

formatting issue in CHANGELOG

resolves scss lint warings

cleanup: unnecessary css classes

adds css class that cleaned up by mistake

replaces snake_case variables name with camelCase

removes unnecessary css class and adds white color border for avatar

moves changelog entry from 8.13 to 8.14

remove bottom margin from avatar-inline

resolves lint warnings

rebased and moves changelog entry to 8.14

fixes avatar shifting on hover

adds entry at top of 8.14 section in CHANGELOG.md

calls sanitization for gl.utils

syncing changelog with master and created changelog files using cli

changes changelog title
2016-11-16 00:03:24 +06:00

48 lines
1.3 KiB
Ruby

module Projects
class ParticipantsService < BaseService
attr_reader :noteable
def execute(noteable)
@noteable = noteable
project_members = sorted(project.team.members)
participants = noteable_owner + participants_in_noteable + all_members + groups + project_members
participants.uniq
end
def noteable_owner
return [] unless noteable && noteable.author.present?
[{
name: noteable.author.name,
username: noteable.author.username,
avatar_url: noteable.author.avatar_url
}]
end
def participants_in_noteable
return [] unless noteable
users = noteable.participants(current_user)
sorted(users)
end
def sorted(users)
users.uniq.to_a.compact.sort_by(&:username).map do |user|
{ username: user.username, name: user.name, avatar_url: user.avatar_url }
end
end
def groups
current_user.authorized_groups.sort_by(&:path).map do |group|
count = group.users.count
{ username: group.path, name: group.name, count: count, avatar_url: group.avatar.url }
end
end
def all_members
count = project.team.members.flatten.count
[{ username: "all", name: "All Project and Group Members", count: count }]
end
end
end