FIX: stop returning self as a candidate for related topics (#31)

This commit is contained in:
Sam 2023-03-31 12:04:17 +11:00 committed by GitHub
parent 0d80d9ec49
commit 6543c50758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -34,6 +34,7 @@ module DiscourseAi
.visible
.listable_topics
.secured
.where("id <> ?", topic.id)
.where(id: candidate_ids)
.order("array_position(ARRAY#{candidate_ids}, id)")
.limit(SiteSetting.ai_embeddings_semantic_related_topics)

View File

@ -29,6 +29,7 @@ describe DiscourseAi::Embeddings::SemanticRelated do
expect(results).to include(normal_topic_1)
expect(results).to include(normal_topic_2)
expect(results).to include(normal_topic_3)
expect(results).to_not include(target)
expect(results).to_not include(unlisted_topic)
expect(results).to_not include(private_topic)
expect(results).to_not include(secured_category_topic)