mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
FIX: Notification counters were being updated incorrectly.
This commit is contained in:
parent
4d8585ac10
commit
6452962f36
|
@ -220,7 +220,8 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def saw_notification_id(notification_id)
|
||||
User.where(["seen_notification_id < ?", notification_id]).update_all ["seen_notification_id = ?", notification_id]
|
||||
User.where(["id = ? and seen_notification_id < ?", id, notification_id])
|
||||
.update_all ["seen_notification_id = ?", notification_id]
|
||||
end
|
||||
|
||||
def publish_notifications_state
|
||||
|
|
14
db/migrate/20130809160751_fix_seen_notification_ids.rb
Normal file
14
db/migrate/20130809160751_fix_seen_notification_ids.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class FixSeenNotificationIds < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
# There was an error where `seen_notification_id` was being updated incorrectly.
|
||||
# This tries to fix some of the bad data.
|
||||
execute "UPDATE users SET
|
||||
seen_notification_id = COALESCE((SELECT MAX(notifications.id)
|
||||
FROM notifications
|
||||
WHERE user_id = users.id AND created_at <= users.last_seen_at), 0)"
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user