adjust qurey to include messages, once everything is read
then mark first_topic_unread_at to be current time
This commit is contained in:
parent
1a1f5d2101
commit
7d59ff67b8
|
@ -85,7 +85,7 @@ class UserStat < ActiveRecord::Base
|
|||
|
||||
exec_sql <<SQL
|
||||
UPDATE user_stats us
|
||||
SET first_topic_unread_at = COALESCE(X.first_unread_at, 'epoch')
|
||||
SET first_topic_unread_at = COALESCE(X.first_unread_at, current_timestamp)
|
||||
FROM
|
||||
(
|
||||
SELECT u.id user_id, MIN(last_unread_at) first_unread_at
|
||||
|
@ -96,7 +96,7 @@ class UserStat < ActiveRecord::Base
|
|||
THEN t.highest_staff_post_number
|
||||
ELSE t.highest_post_number
|
||||
END
|
||||
AND t.deleted_at IS NULL AND t.archetype <> 'private_message'
|
||||
AND t.deleted_at IS NULL
|
||||
GROUP BY u.id
|
||||
) X
|
||||
WHERE X.user_id = us.user_id AND X.first_unread_at <> first_topic_unread_at
|
||||
|
|
|
@ -20,8 +20,8 @@ SQL
|
|||
THEN topics.highest_staff_post_number
|
||||
ELSE topics.highest_post_number
|
||||
END
|
||||
AND topics.deleted_at IS NULL AND topics.archetype <> 'private_message'
|
||||
), 'epoch')
|
||||
AND topics.deleted_at IS NULL
|
||||
), current_timestamp)
|
||||
SQL
|
||||
|
||||
add_index :topics, [:last_unread_at]
|
||||
|
|
Loading…
Reference in New Issue