diff options
author | Josh Frye <joshfng@gmail.com> | 2016-01-27 12:20:17 -0500 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-01-29 13:39:33 -0500 |
commit | d8a292d9078a2de4f3cfe3308a57d5144cb448dd (patch) | |
tree | 6534b2dade5bbccc4f19db717d8e8c3627f53d37 /app/models/broadcast_message.rb | |
parent | dec21517186f7406da2efd76569b4dff4fa711e0 (diff) | |
download | gitlab-ce-d8a292d9078a2de4f3cfe3308a57d5144cb448dd.tar.gz |
Cache BroadcastMessage.current for 5 minutes. Fixes #12770
Diffstat (limited to 'app/models/broadcast_message.rb')
-rw-r--r-- | app/models/broadcast_message.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb index 61119633717..ab3778b6397 100644 --- a/app/models/broadcast_message.rb +++ b/app/models/broadcast_message.rb @@ -26,7 +26,9 @@ class BroadcastMessage < ActiveRecord::Base default_value_for :font, '#FFFFFF' def self.current - where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last + Rails.cache.fetch("broadcast_message_current", expires_in: 5.minutes) do + where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last + end end def active? |