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

Commit e768fa8

Browse files
authored
FIX: Don't regenerate up to date gists (#843)
1 parent 27b5542 commit e768fa8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

app/jobs/regular/hot_topics_gist_batch.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ def execute(args)
1515
summarizer = DiscourseAi::Summarization.topic_gist(topic)
1616
gist = summarizer.existing_summary
1717

18-
summarizer.delete_cached_summaries! if gist && gist.outdated
18+
if gist.blank? || gist.outdated
19+
summarizer.delete_cached_summaries!
1920

20-
summarizer.summarize(Discourse.system_user)
21+
summarizer.summarize(Discourse.system_user)
22+
end
2123
end
2224
end
2325
end

spec/jobs/regular/hot_topics_gist_batch_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@
6161
end
6262

6363
it "does nothing if the gist is up to date" do
64-
subject.execute({})
64+
updated_gist = "They updated me :("
65+
66+
DiscourseAi::Completions::Llm.with_prepared_responses([updated_gist]) do
67+
subject.execute({})
68+
end
6569

6670
gist = AiSummary.gist.find_by(target: topic_1)
67-
expect(gist.summarized_text).to eq(ai_gist.summarized_text)
71+
expect(AiSummary.gist.where(target: topic_1).count).to eq(1)
72+
expect(gist.summarized_text).not_to eq(updated_gist)
6873
expect(gist.original_content_sha).to eq(ai_gist.original_content_sha)
6974
end
7075

0 commit comments

Comments
 (0)