discourse/app/jobs/regular/post_update_topic_tracking_state.rb
jbrw b1f32f2f57
DEV: TopicTrackingState calls should happen in the background (#11682)
* DEV: TopicTrackingState calls should happen in the background

It was observed that calling TopicTrackingState on popular topics could result in a large number of calls to redis, resulting in slow response times when posting replies.

These calls should be moved to a background job.

* DEV: PostUpdateTopicTrackingState should execute on default queue
2021-01-11 15:58:27 -05:00

21 lines
481 B
Ruby

# frozen_string_literal: true
module Jobs
class PostUpdateTopicTrackingState < ::Jobs::Base
def execute(args)
post = Post.find_by(id: args[:post_id])
if post
TopicTrackingState.publish_unmuted(post.topic)
if post.post_number > 1
TopicTrackingState.publish_muted(post.topic)
TopicTrackingState.publish_unread(post)
end
TopicTrackingState.publish_latest(post.topic, post.whisper?)
end
end
end
end