Count +1 votes in issue notes.
This commit is contained in:
parent
ed11ca13e8
commit
8d8b82127f
6 changed files with 81 additions and 15 deletions
|
@ -47,27 +47,27 @@ class Note < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def target
|
||||
if noteable_type == "Commit"
|
||||
if noteable_type == "Commit"
|
||||
project.commit(noteable_id)
|
||||
else
|
||||
else
|
||||
noteable
|
||||
end
|
||||
# Temp fix to prevent app crash
|
||||
# if note commit id doesnt exist
|
||||
rescue
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
# Check if we can notify commit author
|
||||
# with email about our comment
|
||||
#
|
||||
# If commit author email exist in project
|
||||
# and commit author is not passed user we can
|
||||
# If commit author email exist in project
|
||||
# and commit author is not passed user we can
|
||||
# send email to him
|
||||
#
|
||||
# params:
|
||||
# user - current user
|
||||
#
|
||||
#
|
||||
# return:
|
||||
# Boolean
|
||||
#
|
||||
|
@ -81,12 +81,18 @@ class Note < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def commit_author
|
||||
@commit_author ||=
|
||||
project.users.find_by_email(target.author_email) ||
|
||||
@commit_author ||=
|
||||
project.users.find_by_email(target.author_email) ||
|
||||
project.users.find_by_name(target.author_name)
|
||||
rescue
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
# Returns true if this is an upvote note,
|
||||
# otherwise false is returned
|
||||
def upvote?
|
||||
note =~ /^\+1/ ? true : false
|
||||
end
|
||||
end
|
||||
# == Schema Information
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue