summaryrefslogtreecommitdiff
path: root/app/models/award_emoji.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-07-17 19:36:29 +0100
committerFatih Acet <acetfatih@gmail.com>2017-07-21 22:35:26 +0300
commitdb0b7fb39e921728385b3287d206aabbeb88690e (patch)
treed2c1f43d192ce30cf3185cf104ec2ffcf1d02704 /app/models/award_emoji.rb
parentaed5632ca4d848ebc1e0cfed3465807cf36afe9e (diff)
downloadgitlab-ce-db0b7fb39e921728385b3287d206aabbeb88690e.tar.gz
Expire ETag cache on note when award emoji changes
Diffstat (limited to 'app/models/award_emoji.rb')
-rw-r--r--app/models/award_emoji.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index 91b62dabbcd..1f07caf3366 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -17,6 +17,9 @@ class AwardEmoji < ActiveRecord::Base
scope :downvotes, -> { where(name: DOWNVOTE_NAME) }
scope :upvotes, -> { where(name: UPVOTE_NAME) }
+ after_save :expire_etag_cache
+ after_destroy :expire_etag_cache
+
class << self
def votes_for_collection(ids, type)
select('name', 'awardable_id', 'COUNT(*) as count')
@@ -32,4 +35,10 @@ class AwardEmoji < ActiveRecord::Base
def upvote?
self.name == UPVOTE_NAME
end
+
+ def expire_etag_cache
+ return unless awardable.is_a?(Note)
+
+ awardable.expire_etag_cache
+ end
end