diff options
| author | Drew Blessing <drew.blessing@buckle.com> | 2013-12-13 13:40:45 -0600 |
|---|---|---|
| committer | Drew Blessing <drew.blessing@buckle.com> | 2013-12-13 13:40:45 -0600 |
| commit | 63723ef6df788391ed776441421ae482ad4fbd82 (patch) | |
| tree | d7f1d27b5f6bfe7ca0f7162ea12658178d97cc4a /app/models/note.rb | |
| parent | ee53b73986ba4c9dd2f0c726a44718acb8febaf8 (diff) | |
| download | gitlab-ce-63723ef6df788391ed776441421ae482ad4fbd82.tar.gz | |
Fix dashboard event caching
Diffstat (limited to 'app/models/note.rb')
| -rw-r--r-- | app/models/note.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 8284da8616f..b23f7df7742 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -239,4 +239,19 @@ class Note < ActiveRecord::Base def noteable_type=(sType) super(sType.to_s.classify.constantize.base_class.to_s) end + + # Reset notes events cache + # + # Since we do cache @event we need to reset cache in special cases: + # * when a note is updated + # * when a note is removed + # 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: 'Note'). + order('id DESC').limit(100). + update_all(updated_at: Time.now) + end end |
