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

Commit 1807ff5

Browse files
committed
DEV: Introduce an upsert-like summarize
1 parent 184a180 commit 1807ff5

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

app/jobs/regular/hot_topics_gist_batch.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ def execute(_args)
1515
summarizer = DiscourseAi::Summarization.topic_gist(topic)
1616
gist = summarizer.existing_summary
1717

18-
if gist.blank? || gist.outdated
19-
summarizer.delete_cached_summaries!
20-
21-
summarizer.summarize(Discourse.system_user)
22-
end
18+
summarizer.force_summarize(Discourse.system_user) if gist.blank? || gist.outdated
2319
end
2420
end
2521
end

app/jobs/regular/update_hot_topic_gist.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def execute(args)
1919
return if gist.blank?
2020
return if !gist.outdated
2121

22-
summarizer.delete_cached_summaries!
23-
summarizer.summarize(Discourse.system_user)
22+
summarizer.force_summarize(Discourse.system_user)
2423
end
2524
end
2625
end

lib/summarization/fold_content.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ def delete_cached_summaries!
6666
AiSummary.where(target: strategy.target, summary_type: strategy.type).destroy_all
6767
end
6868

69+
def force_summarize(user, &on_partial_blk)
70+
delete_cached_summaries!
71+
summarize(user, &on_partial_blk)
72+
end
73+
6974
private
7075

7176
attr_reader :persist_summaries

0 commit comments

Comments
 (0)