Retrospring/app/models/user/notification_methods.rb

15 lines
382 B
Ruby
Raw Normal View History

2023-02-25 06:46:11 -08:00
# frozen_string_literal: true
module User::NotificationMethods
def unread_notification_count
Rails.cache.fetch("#{notification_cache_key}/unread_notification_count") do
count = Notification.for(self).where(new: true).count
return nil unless count.positive?
count
end
end
def notification_cache_key = "#{cache_key}-#{notifications_updated_at}"
end