FIX: AI Helper category / tag suggestion when user does not categories muted (#1042)

This commit is contained in:
Rafael dos Santos Silva 2024-12-23 15:58:26 -03:00 committed by GitHub
parent ceac6e5efb
commit 792df58fbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,11 +109,13 @@ module DiscourseAi
schema schema
.asymmetric_similarity_search(raw_vector, limit: limit, offset: 0) do |builder| .asymmetric_similarity_search(raw_vector, limit: limit, offset: 0) do |builder|
builder.join("topics t on t.id = topic_id") builder.join("topics t on t.id = topic_id")
unless muted_category_ids.empty?
builder.where(<<~SQL, exclude_category_ids: muted_category_ids.map(&:to_i)) builder.where(<<~SQL, exclude_category_ids: muted_category_ids.map(&:to_i))
t.category_id NOT IN (:exclude_category_ids) AND t.category_id NOT IN (:exclude_category_ids) AND
t.category_id NOT IN (SELECT categories.id FROM categories WHERE categories.parent_category_id IN (:exclude_category_ids)) t.category_id NOT IN (SELECT categories.id FROM categories WHERE categories.parent_category_id IN (:exclude_category_ids))
SQL SQL
end end
end
.map { |r| [r.topic_id, r.distance] } .map { |r| [r.topic_id, r.distance] }
end end
end end