FIX: exclude non visible topics from report context (#375)

Generally non visible topics are not that interesting, do not add
this noise to the report context
This commit is contained in:
Sam 2023-12-21 19:08:36 +11:00 committed by GitHub
parent 8feb3ad4db
commit 37dd98c937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -33,6 +33,7 @@ module DiscourseAi
.where("posts.created_at >= ?", @start_date)
.joins(topic: :category)
.includes(:topic, :user)
.where("topics.visible")
.where("posts.created_at < ?", @start_date + @duration)
.where("posts.post_type = ?", Post.types[:regular])
.where("posts.hidden_at IS NULL")

View File

@ -59,6 +59,14 @@ module DiscourseAi
end
end
it "will exclude non visible topics" do
post_with_likes3.topic.update(visible: false)
context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day)
expect(context).not_to include("topic_id: #{topic_with_likes.id}")
end
it "always includes info from last posts on topic" do
context =
ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day, max_posts: 1)