From eeff092eaddd102592f3151e266e9e825129088b Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 11 Aug 2014 10:26:46 +1000 Subject: [PATCH] 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 --- app/jobs/scheduled/ensure_db_consistency.rb | 1 - app/models/topic_user.rb | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/jobs/scheduled/ensure_db_consistency.rb b/app/jobs/scheduled/ensure_db_consistency.rb index d04b30f3c71..83896fb2773 100644 --- a/app/jobs/scheduled/ensure_db_consistency.rb +++ b/app/jobs/scheduled/ensure_db_consistency.rb @@ -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! diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index 1816f34cbe1..e2c4bdff667 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -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 < 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