Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit b637cc3

Browse files
committed
FIX: Only enqueue fast-track gist for hot hot hot topics
1 parent 1807ff5 commit b637cc3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/summarization/entry_point.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@ def inject_into(plugin)
4848
# instead of using a scheduled job.
4949
plugin.on(:topic_hot_scores_updated) { Jobs.enqueue(:hot_topics_gist_batch) }
5050

51+
# As this event can be triggered quite often, let's be overly cautious enqueueing
52+
# jobs if the feature is disabled.
5153
plugin.on(:post_created) do |post|
52-
Jobs.enqueue(:update_hot_topic_gist, topic_id: post&.topic_id)
54+
if SiteSetting.discourse_ai_enabled && SiteSetting.ai_summarization_enabled &&
55+
SiteSetting.ai_summarize_max_hot_topics_gists_per_batch > 0 && post.topic
56+
hot_score = TopicHotScore.find_by(topic: post.topic)
57+
58+
if hot_score.exists? && hot_score.updated_at > 1.day.ago
59+
Jobs.enqueue(:update_hot_topic_gist, topic_id: post&.topic_id)
60+
end
61+
end
5362
end
5463
end
5564
end

0 commit comments

Comments
 (0)