mirror of
https://github.com/discourse/discourse.git
synced 2025-03-29 10:26:40 +08:00
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
|
exec_sql <<SQL
|
||||||
UPDATE user_stats us
|
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
|
FROM
|
||||||
(
|
(
|
||||||
SELECT u.id user_id, MIN(last_unread_at) first_unread_at
|
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
|
THEN t.highest_staff_post_number
|
||||||
ELSE t.highest_post_number
|
ELSE t.highest_post_number
|
||||||
END
|
END
|
||||||
AND t.deleted_at IS NULL AND t.archetype <> 'private_message'
|
AND t.deleted_at IS NULL
|
||||||
GROUP BY u.id
|
GROUP BY u.id
|
||||||
) X
|
) X
|
||||||
WHERE X.user_id = us.user_id AND X.first_unread_at <> first_topic_unread_at
|
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
|
THEN topics.highest_staff_post_number
|
||||||
ELSE topics.highest_post_number
|
ELSE topics.highest_post_number
|
||||||
END
|
END
|
||||||
AND topics.deleted_at IS NULL AND topics.archetype <> 'private_message'
|
AND topics.deleted_at IS NULL
|
||||||
), 'epoch')
|
), current_timestamp)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
add_index :topics, [:last_unread_at]
|
add_index :topics, [:last_unread_at]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user