summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/broadcast_message.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb
index 61119633717..8a0a8a4c2a9 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: 1.minute) do
+ where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last
+ end
end
def active?