From 1715aa66d90196b1a74ba8b88e0ab21f5cab43f3 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 8 Apr 2013 10:51:01 -0400 Subject: [PATCH] Fixes issue with featuring topic users --- lib/post_creator.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/post_creator.rb b/lib/post_creator.rb index 052a454ac..47081fc93 100644 --- a/lib/post_creator.rb +++ b/lib/post_creator.rb @@ -94,12 +94,6 @@ class PostCreator # Extract links TopicLink.extract_from(post) - # Enqueue a job to feature the users in the topic - Jobs.enqueue(:feature_topic_users, topic_id: topic.id) - - # Trigger post processing - post.trigger_post_process - # Store unique post key if SiteSetting.unique_posts_mins > 0 $redis.setex(post.unique_post_key, SiteSetting.unique_posts_mins.minutes.to_i, "1") @@ -115,7 +109,6 @@ class PostCreator # Track the topic TopicUser.auto_track(@user.id, topic.id, TopicUser.notification_reasons[:created_post]) - if @user.id != topic.user_id @user.update_topic_reply_count end @@ -137,9 +130,15 @@ class PostCreator post.save_reply_relationships end + # We need to enqueue jobs after the transaction. Otherwise they might begin before the data has + # been comitted. + Jobs.enqueue(:feature_topic_users, topic_id: topic.id) + post.trigger_post_process + post end + # Shortcut def self.create(user, opts) PostCreator.new(user, opts).create