Commit 55c4996b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'cache-broadcast-message-current' into 'master'

Cache BroadcastMessage.current. Fixes #12770



See merge request !2633
parents f862b4ae a6d6cfaf
......@@ -26,8 +26,10 @@ class BroadcastMessage < ActiveRecord::Base
default_value_for :font, '#FFFFFF'
def self.current
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?
started? && !ended?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment