FIX: Publish notification state in `after_commit` hook.

`after_save` is still wrapped in a transaction and
we were getting intermittent failures with notifications
state not being published.
This commit is contained in:
Guo Xiang Tan 2017-03-20 11:38:34 +08:00
parent 11dbadb96f
commit a567e6bec9
1 changed files with 1 additions and 3 deletions

View File

@ -12,10 +12,8 @@ class Notification < ActiveRecord::Base
scope :visible , lambda { joins('LEFT JOIN topics ON notifications.topic_id = topics.id') scope :visible , lambda { joins('LEFT JOIN topics ON notifications.topic_id = topics.id')
.where('topics.id IS NULL OR topics.deleted_at IS NULL') } .where('topics.id IS NULL OR topics.deleted_at IS NULL') }
after_save :refresh_notification_count
after_destroy :refresh_notification_count
after_commit :send_email after_commit :send_email
after_commit :refresh_notification_count
def self.ensure_consistency! def self.ensure_consistency!
Notification.exec_sql(" Notification.exec_sql("