Fix vote counting
This commit is contained in:
parent
6c6f415cae
commit
ae067ee322
7 changed files with 186 additions and 117 deletions
|
@ -85,7 +85,9 @@ class Note < ActiveRecord::Base
|
|||
# Returns true if this is a downvote note,
|
||||
# otherwise false is returned
|
||||
def downvote?
|
||||
note.start_with?('-1') || note.start_with?(':-1:')
|
||||
votable? && (note.start_with?('-1') ||
|
||||
note.start_with?(':-1:')
|
||||
)
|
||||
end
|
||||
|
||||
def for_commit?
|
||||
|
@ -100,6 +102,10 @@ class Note < ActiveRecord::Base
|
|||
line_code.present?
|
||||
end
|
||||
|
||||
def for_issue?
|
||||
noteable_type == "Issue"
|
||||
end
|
||||
|
||||
def for_merge_request?
|
||||
noteable_type == "MergeRequest"
|
||||
end
|
||||
|
@ -150,6 +156,12 @@ class Note < ActiveRecord::Base
|
|||
# Returns true if this is an upvote note,
|
||||
# otherwise false is returned
|
||||
def upvote?
|
||||
note.start_with?('+1') || note.start_with?(':+1:')
|
||||
votable? && (note.start_with?('+1') ||
|
||||
note.start_with?(':+1:')
|
||||
)
|
||||
end
|
||||
|
||||
def votable?
|
||||
for_issue? || (for_merge_request? && !for_diff_line?)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue