Browse Source

feat: add active scope

pull/2131/head
natdeanlewissoftwire 2 years ago
parent
commit
253cfefabb
  1. 2
      app/models/notification.rb
  2. 2
      app/models/user.rb

2
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

2
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

Loading…
Cancel
Save