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

Commit 4aee428

Browse files
committed
FEATURE: Calculate gists from non hot topics too
1 parent 54f2d34 commit 4aee428

File tree

3 files changed

+2
-34
lines changed

3 files changed

+2
-34
lines changed

app/jobs/regular/update_hot_topic_gist.rb renamed to app/jobs/regular/fast_track_topic_gist.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module ::Jobs
4-
class UpdateHotTopicGist < ::Jobs::Base
4+
class FastTrackTopicGist < ::Jobs::Base
55
sidekiq_options retry: false
66

77
def execute(args)
@@ -12,8 +12,6 @@ def execute(args)
1212
topic = Topic.find_by(id: args[:topic_id])
1313
return if topic.blank?
1414

15-
return if !TopicHotScore.where(topic: topic).exists?
16-
1715
summarizer = DiscourseAi::Summarization.topic_gist(topic)
1816
gist = summarizer.existing_summary
1917
return if gist.blank?

app/jobs/regular/hot_topics_gist_batch.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/summarization/entry_point.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,12 @@ def inject_into(plugin)
3535
object.ai_gist_summary&.summarized_text
3636
end
3737

38-
# To make sure hot topic gists are inmediately up to date, we rely on this event
39-
# instead of using a scheduled job.
40-
plugin.on(:topic_hot_scores_updated) { Jobs.enqueue(:hot_topics_gist_batch) }
41-
4238
# As this event can be triggered quite often, let's be overly cautious enqueueing
4339
# jobs if the feature is disabled.
4440
plugin.on(:post_created) do |post|
4541
if SiteSetting.discourse_ai_enabled && SiteSetting.ai_summarization_enabled &&
4642
SiteSetting.ai_summarize_max_hot_topics_gists_per_batch > 0 && post.topic
47-
hot_score = TopicHotScore.find_by(topic: post.topic)
48-
49-
if hot_score.present? && hot_score.updated_at > 1.day.ago
50-
Jobs.enqueue(:update_hot_topic_gist, topic_id: post&.topic_id)
51-
end
43+
Jobs.enqueue(:fast_track_topic_gist, topic_id: post&.topic_id)
5244
end
5345
end
5446
end

0 commit comments

Comments
 (0)