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:
authorHiroyuki Sato <sathiroyuki@gmail.com>2017-08-30 10:48:55 +0300
committerPhil Hughes <me@iamphill.com>2017-08-30 10:48:55 +0300
commit7187395ef13d8d84a145d1b5251882ebada3f7f2 (patch)
tree06188448a7059648d5ca99c159f525eaf3499cc3 /app/models/concerns/awardable.rb
parentdf8ca5aaab21f47c328cc15f2c454b9cc97a3ed5 (diff)
Add filter by my reaction
Diffstat (limited to 'app/models/concerns/awardable.rb')
-rw-r--r--app/models/concerns/awardable.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb
index f4f9b037957..9adc309a22b 100644
--- a/app/models/concerns/awardable.rb
+++ b/app/models/concerns/awardable.rb
@@ -11,6 +11,21 @@ module Awardable
end
module ClassMethods
+ def awarded(user, name)
+ sql = <<~EOL
+ EXISTS (
+ SELECT TRUE
+ FROM award_emoji
+ WHERE user_id = :user_id AND
+ name = :name AND
+ awardable_type = :awardable_type AND
+ awardable_id = #{self.arel_table.name}.id
+ )
+ EOL
+
+ where(sql, user_id: user.id, name: name, awardable_type: self.name)
+ end
+
def order_upvotes_desc
order_votes_desc(AwardEmoji::UPVOTE_NAME)
end