Clean up code somewhat.
This commit is contained in:
parent
990b476faa
commit
630e879066
|
@ -139,15 +139,14 @@ class Commit
|
|||
users << author
|
||||
users << committer
|
||||
|
||||
mentions = []
|
||||
mentions << self.mentioned_users(current_user, project)
|
||||
users.push *self.mentioned_users(current_user, project)
|
||||
|
||||
notes(project).each do |note|
|
||||
users << note.author
|
||||
mentions << note.mentioned_users(current_user, project)
|
||||
users.push *note.mentioned_users(current_user, project)
|
||||
end
|
||||
|
||||
users.concat(mentions.reduce([], :|)).uniq
|
||||
users.uniq
|
||||
end
|
||||
|
||||
def notes(project)
|
||||
|
|
|
@ -123,15 +123,14 @@ module Issuable
|
|||
users << author
|
||||
users << assignee if is_assigned?
|
||||
|
||||
mentions = []
|
||||
mentions << self.mentioned_users(current_user)
|
||||
users.push *self.mentioned_users(current_user)
|
||||
|
||||
notes.each do |note|
|
||||
users << note.author
|
||||
mentions << note.mentioned_users(current_user)
|
||||
users.push *note.mentioned_users(current_user)
|
||||
end
|
||||
|
||||
users.concat(mentions.reduce([], :|)).uniq
|
||||
users.uniq
|
||||
end
|
||||
|
||||
def subscribed?(user)
|
||||
|
|
|
@ -91,14 +91,12 @@ class Snippet < ActiveRecord::Base
|
|||
users = []
|
||||
users << author
|
||||
|
||||
mentions = []
|
||||
|
||||
notes.each do |note|
|
||||
users << note.author
|
||||
mentions << note.mentioned_users(current_user)
|
||||
users.push *note.mentioned_users(current_user)
|
||||
end
|
||||
|
||||
users.concat(mentions.reduce([], :|)).uniq
|
||||
users.uniq
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
|
@ -13,19 +13,21 @@ module Projects
|
|||
end
|
||||
|
||||
def participants_in(type, id)
|
||||
users = case type
|
||||
users =
|
||||
case type
|
||||
when "Issue"
|
||||
issue = project.issues.find_by_iid(id)
|
||||
issue ? issue.participants(current_user) : []
|
||||
issue.participants(current_user) if issue
|
||||
when "MergeRequest"
|
||||
merge_request = project.merge_requests.find_by_iid(id)
|
||||
merge_request ? merge_request.participants(current_user) : []
|
||||
merge_request.participants(current_user) if merge_request
|
||||
when "Commit"
|
||||
commit = project.repository.commit(id)
|
||||
commit ? commit.participants(project, current_user) : []
|
||||
else
|
||||
[]
|
||||
commit.participants(project, current_user) if commit
|
||||
end
|
||||
|
||||
return [] unless users
|
||||
|
||||
sorted(users)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue