summaryrefslogtreecommitdiff
path: root/app/models/award_emoji.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-12 12:09:39 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-12 12:09:39 +0000
commitf81141c25d0dd79de8c07559bf268cb6e0d287d3 (patch)
treea0f700b90845f738cc2037cbbfb7a980c36137ac /app/models/award_emoji.rb
parent12de063de4663766a43d6c3e0883a686d66ab401 (diff)
downloadgitlab-ce-f81141c25d0dd79de8c07559bf268cb6e0d287d3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/award_emoji.rb')
-rw-r--r--app/models/award_emoji.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index 7679f6fce72..dc37d73df85 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -27,6 +27,9 @@ class AwardEmoji < ApplicationRecord
after_save :expire_cache
after_destroy :expire_cache
+ after_save :update_awardable_upvotes_count
+ after_destroy :update_awardable_upvotes_count
+
class << self
def votes_for_collection(ids, type)
select('name', 'awardable_id', 'COUNT(*) as count')
@@ -64,6 +67,14 @@ class AwardEmoji < ApplicationRecord
awardable.try(:bump_updated_at)
awardable.try(:expire_etag_cache)
end
+
+ private
+
+ def update_awardable_upvotes_count
+ return unless upvote? && awardable.has_attribute?(:upvotes_count)
+
+ awardable.update_column(:upvotes_count, awardable.upvotes)
+ end
end
AwardEmoji.prepend_mod_with('AwardEmoji')