Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-11-11 16:12:51 +0300
committerValery Sizov <vsv2711@gmail.com>2015-11-19 02:25:27 +0300
commitfd2c0fe446c7f761b845c91307ef8110d869e8e8 (patch)
tree1a2b6c53f6a4c5c24fcb57adad7a2cd115e72623 /app/models/note.rb
parent61867abeeccf9e6f65ba38c365d8bdf6b61387f4 (diff)
award emoji
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb46
1 files changed, 8 insertions, 38 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 0b3aa30abd7..458d433211c 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -50,6 +50,8 @@ class Note < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Scopes
+ scope :awards, ->{ where("is_award IS TRUE") }
+ scope :nonawards, ->{ where("is_award IS FALSE") }
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :inline, ->{ where("line_code IS NOT NULL") }
scope :not_inline, ->{ where(line_code: [nil, '']) }
@@ -97,6 +99,12 @@ class Note < ActiveRecord::Base
def search(query)
where("LOWER(note) like :query", query: "%#{query.downcase}%")
end
+
+ def grouped_awards
+ select(:note).distinct.map do |note|
+ [ note.note, where(note: note.note) ]
+ end
+ end
end
def cross_reference?
@@ -288,44 +296,6 @@ class Note < ActiveRecord::Base
nil
end
- DOWNVOTES = %w(-1 :-1: :thumbsdown: :thumbs_down_sign:)
-
- # Check if the note is a downvote
- def downvote?
- votable? && note.start_with?(*DOWNVOTES)
- end
-
- UPVOTES = %w(+1 :+1: :thumbsup: :thumbs_up_sign:)
-
- # Check if the note is an upvote
- def upvote?
- votable? && note.start_with?(*UPVOTES)
- end
-
- def superceded?(notes)
- return false unless vote?
-
- notes.each do |note|
- next if note == self
-
- if note.vote? &&
- self[:author_id] == note[:author_id] &&
- self[:created_at] <= note[:created_at]
- return true
- end
- end
-
- false
- end
-
- def vote?
- upvote? || downvote?
- end
-
- def votable?
- for_issue? || (for_merge_request? && !for_diff_line?)
- end
-
# Mentionable override.
def gfm_reference(from_project = nil)
noteable.gfm_reference(from_project)