2024-10-25 11:38:49 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ::Jobs
|
2024-11-26 11:44:12 -05:00
|
|
|
class FastTrackTopicGist < ::Jobs::Base
|
2024-10-25 11:38:49 -04:00
|
|
|
sidekiq_options retry: false
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
return if !SiteSetting.discourse_ai_enabled
|
|
|
|
return if !SiteSetting.ai_summarization_enabled
|
2024-11-26 11:44:12 -05:00
|
|
|
return if !SiteSetting.ai_summary_gists_enabled
|
2024-10-25 11:38:49 -04:00
|
|
|
|
|
|
|
topic = Topic.find_by(id: args[:topic_id])
|
|
|
|
return if topic.blank?
|
|
|
|
|
|
|
|
summarizer = DiscourseAi::Summarization.topic_gist(topic)
|
|
|
|
gist = summarizer.existing_summary
|
2024-12-13 17:36:34 -05:00
|
|
|
return if gist.present? && (!gist.outdated || gist.created_at >= 5.minutes.ago)
|
2024-10-25 11:38:49 -04:00
|
|
|
|
|
|
|
summarizer.force_summarize(Discourse.system_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|