mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-14 15:16:04 +10:00
Cache BroadcastMessage.current for 5 minutes. Fixes #12770
This commit is contained in:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user