mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:00:32 -06:00
PERF/FIX: Dismiss Post coming back
Now that post numbers are monotonically increasing we should not need this job Stuff should just self correct as users browser along Corrected the job not to reset the disimissed posts in case we need it
This commit is contained in:
parent
0b5e19303d
commit
eeff092ead
@ -4,7 +4,6 @@ module Jobs
|
||||
every 12.hours
|
||||
|
||||
def execute(args)
|
||||
TopicUser.ensure_consistency!
|
||||
UserVisit.ensure_consistency!
|
||||
Group.refresh_automatic_groups!
|
||||
Notification.ensure_consistency!
|
||||
|
@ -230,10 +230,15 @@ class TopicUser < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.ensure_consistency!(topic_id=nil)
|
||||
# TODO this needs some reworking, when we mark stuff skipped
|
||||
# we up these numbers so they are not in-sync
|
||||
# the simple fix is to add a column here, but table is already quite big
|
||||
# long term we want to split up topic_users and allow for this better
|
||||
builder = SqlBuilder.new <<SQL
|
||||
|
||||
UPDATE topic_users t
|
||||
SET
|
||||
last_read_post_number = last_read,
|
||||
last_read_post_number = LEAST(GREATEST(last_read, last_read_post_number), max_post_number),
|
||||
seen_post_count = LEAST(max_post_number,GREATEST(t.seen_post_count, last_read))
|
||||
FROM (
|
||||
SELECT topic_id, user_id, MAX(post_number) last_read
|
||||
@ -251,7 +256,7 @@ SQL
|
||||
X.topic_id = t.topic_id AND
|
||||
X.user_id = t.user_id AND
|
||||
(
|
||||
last_read_post_number <> last_read OR
|
||||
last_read_post_number <> LEAST(GREATEST(last_read, last_read_post_number), max_post_number) OR
|
||||
seen_post_count <> LEAST(max_post_number,GREATEST(t.seen_post_count, last_read))
|
||||
)
|
||||
SQL
|
||||
|
Loading…
Reference in New Issue
Block a user