mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-07 12:08:13 +00:00
a2b1ea3c63
* FEATURE: Fast-track gist regeneration when a hot topic gets a new post * DEV: Introduce an upsert-like summarize * FIX: Only enqueue fast-track gist for hot hot hot topics --------- Co-authored-by: Rafael Silva <xfalcox@gmail.com>
23 lines
765 B
Ruby
23 lines
765 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ::Jobs
|
|
class HotTopicsGistBatch < ::Jobs::Base
|
|
def execute(_args)
|
|
return if !SiteSetting.discourse_ai_enabled
|
|
return if !SiteSetting.ai_summarization_enabled
|
|
return if SiteSetting.ai_summarize_max_hot_topics_gists_per_batch.zero?
|
|
|
|
Topic
|
|
.joins("JOIN topic_hot_scores on topics.id = topic_hot_scores.topic_id")
|
|
.order("topic_hot_scores.score DESC")
|
|
.limit(SiteSetting.ai_summarize_max_hot_topics_gists_per_batch)
|
|
.each do |topic|
|
|
summarizer = DiscourseAi::Summarization.topic_gist(topic)
|
|
gist = summarizer.existing_summary
|
|
|
|
summarizer.force_summarize(Discourse.system_user) if gist.blank? || gist.outdated
|
|
end
|
|
end
|
|
end
|
|
end
|