diff --git a/app/models/notification.rb b/app/models/notification.rb index 9e3a8482f..f136948f6 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,3 +1,5 @@ class Notification < ApplicationRecord acts_as_readable + + scope :active, -> { where("start_date <= ?", Time.zone.now).where("end_date >= ?", Time.zone.now) } end diff --git a/app/models/user.rb b/app/models/user.rb index 1aa7898e1..1f6412b6a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -230,7 +230,7 @@ class User < ApplicationRecord end def active_unread_notifications - Notification.unread_by(self) + Notification.active.unread_by(self) end def oldest_active_unread_notification