FIX: Don't regenerate up to date gists (#843)
This commit is contained in:
parent
27b5542357
commit
e768fa877e
|
@ -15,10 +15,12 @@ module ::Jobs
|
||||||
summarizer = DiscourseAi::Summarization.topic_gist(topic)
|
summarizer = DiscourseAi::Summarization.topic_gist(topic)
|
||||||
gist = summarizer.existing_summary
|
gist = summarizer.existing_summary
|
||||||
|
|
||||||
summarizer.delete_cached_summaries! if gist && gist.outdated
|
if gist.blank? || gist.outdated
|
||||||
|
summarizer.delete_cached_summaries!
|
||||||
|
|
||||||
summarizer.summarize(Discourse.system_user)
|
summarizer.summarize(Discourse.system_user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,10 +61,15 @@ RSpec.describe Jobs::HotTopicsGistBatch do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does nothing if the gist is up to date" do
|
it "does nothing if the gist is up to date" do
|
||||||
|
updated_gist = "They updated me :("
|
||||||
|
|
||||||
|
DiscourseAi::Completions::Llm.with_prepared_responses([updated_gist]) do
|
||||||
subject.execute({})
|
subject.execute({})
|
||||||
|
end
|
||||||
|
|
||||||
gist = AiSummary.gist.find_by(target: topic_1)
|
gist = AiSummary.gist.find_by(target: topic_1)
|
||||||
expect(gist.summarized_text).to eq(ai_gist.summarized_text)
|
expect(AiSummary.gist.where(target: topic_1).count).to eq(1)
|
||||||
|
expect(gist.summarized_text).not_to eq(updated_gist)
|
||||||
expect(gist.original_content_sha).to eq(ai_gist.original_content_sha)
|
expect(gist.original_content_sha).to eq(ai_gist.original_content_sha)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue