Skip to content
Snippets Groups Projects
Commit d8a292d9 authored by Josh Frye's avatar Josh Frye
Browse files

Cache BroadcastMessage.current for 5 minutes. Fixes #12770

parent dec21517
No related branches found
No related tags found
No related merge requests found
Loading
@@ -26,8 +26,10 @@ class BroadcastMessage < ActiveRecord::Base
Loading
@@ -26,8 +26,10 @@ class BroadcastMessage < ActiveRecord::Base
default_value_for :font, '#FFFFFF' default_value_for :font, '#FFFFFF'
   
def self.current def self.current
Rails.cache.fetch("broadcast_message_current", expires_in: 5.minutes) do
where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last
end end
end
   
def active? def active?
started? && !ended? started? && !ended?
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment