diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 12:09:39 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 12:09:39 +0000 |
commit | f81141c25d0dd79de8c07559bf268cb6e0d287d3 (patch) | |
tree | a0f700b90845f738cc2037cbbfb7a980c36137ac /app/models/award_emoji.rb | |
parent | 12de063de4663766a43d6c3e0883a686d66ab401 (diff) | |
download | gitlab-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.rb | 11 |
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') |