* 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
15 lines
308 B
Ruby
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
|