1
0
mirror of synced 2026-08-31 20:14:59 +00:00

DEV: Add apply_modifier for SemanticTopicQuery topics list (#830)

This commit is contained in:
Mark VanLandingham
2024-10-10 12:13:16 -05:00
committed by GitHub
parent c5b323fc07
commit 52d90cf1bc
2 changed files with 27 additions and 5 deletions
+5 -5
View File
@@ -16,12 +16,12 @@ class DiscourseAi::Embeddings::SemanticTopicQuery < TopicQuery
create_list(:semantic_related, query_opts) do |topics|
candidate_ids = DiscourseAi::Embeddings::SemanticRelated.new.related_topic_ids_for(topic)
list =
topics
.where.not(id: topic.id)
.where(id: candidate_ids)
.order("array_position(ARRAY#{candidate_ids}, topics.id)") # array_position forces the order of the topics to be preserved
list = topics.where.not(id: topic.id).where(id: candidate_ids)
list = DiscoursePluginRegistry.apply_modifier(:semantic_related_topics_query, list)
# array_position forces the order of the topics to be preserved
list = list.order("array_position(ARRAY#{candidate_ids}, topics.id)")
list = remove_muted(list, @user, query_opts)
end
end