Cache BroadcastMessage.current for 5 minutes. Fixes #12770

This commit is contained in:
Josh Frye
2016-01-29 13:39:33 -05:00
parent dec2151718
commit d8a292d907
+3 -1
View File
@@ -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?