docbrown/app/labor/notification_counter.rb
Andy Zhao 5ace9a5fc9 Organization Notifications (#1762)
* Add spec for org reaction notification

* Add organization_id to notifications

* Add validations for user and org IDs

* Move comment json_data out of loop

* Use actual column names instead

* Add organization filters

* Remove extra text-align

* Add organization filtering

* Refactor to reduce complexity

* Add receiver argument to handle orgs

* Add has_many notifications for orgs

* Add follow notifications for orgs

* Add comment notifications for orgs

* Rename some tests for specificity

* Add mark org notifications as read functionality

* Add radix to parseInt

* Define json_data outside of loop

* Notify org followers of a new post as well

* Move test to proper location

* Add test for aggregated method

* Make send org reaction notification more readable

* Test the rest of the notification model

* Refactor tag adjustment spec

* Fix extra html
2019-02-25 14:25:37 -08:00

15 lines
308 B
Ruby

class NotificationCounter
def initialize(receiver)
@receiver = receiver
end
def unread_notification_count
return 0 if Rails.env.test?
@receiver.notifications.where(read: false).count
end
def set_to_zero
@receiver.notifications.where(read: false).update_all(read: true)
end
end