diff options
author | Drew Blessing <drew.blessing@buckle.com> | 2013-12-13 23:40:45 +0400 |
---|---|---|
committer | Drew Blessing <drew.blessing@buckle.com> | 2013-12-13 23:40:45 +0400 |
commit | 63723ef6df788391ed776441421ae482ad4fbd82 (patch) | |
tree | d7f1d27b5f6bfe7ca0f7162ea12658178d97cc4a /app/models/issue.rb | |
parent | ee53b73986ba4c9dd2f0c726a44718acb8febaf8 (diff) |
Fix dashboard event caching
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index d350b237d37..b3609cf2f45 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -64,4 +64,18 @@ class Issue < ActiveRecord::Base def gfm_reference "issue ##{iid}" end + + # Reset issue events cache + # + # Since we do cache @event we need to reset cache in special cases: + # * when an issue is updated + # Events cache stored like events/23-20130109142513. + # The cache key includes updated_at timestamp. + # Thus it will automatically generate a new fragment + # when the event is updated because the key changes. + def reset_events_cache + Event.where(target_id: self.id, target_type: 'Issue'). + order('id DESC').limit(100). + update_all(updated_at: Time.now) + end end |