Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 792df58

Browse files
authored
FIX: AI Helper category / tag suggestion when user does not categories muted (#1042)
1 parent ceac6e5 commit 792df58

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/ai_helper/semantic_categorizer.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ def nearest_neighbors(limit: 100)
109109
schema
110110
.asymmetric_similarity_search(raw_vector, limit: limit, offset: 0) do |builder|
111111
builder.join("topics t on t.id = topic_id")
112-
builder.where(<<~SQL, exclude_category_ids: muted_category_ids.map(&:to_i))
113-
t.category_id NOT IN (:exclude_category_ids) AND
114-
t.category_id NOT IN (SELECT categories.id FROM categories WHERE categories.parent_category_id IN (:exclude_category_ids))
115-
SQL
112+
unless muted_category_ids.empty?
113+
builder.where(<<~SQL, exclude_category_ids: muted_category_ids.map(&:to_i))
114+
t.category_id NOT IN (:exclude_category_ids) AND
115+
t.category_id NOT IN (SELECT categories.id FROM categories WHERE categories.parent_category_id IN (:exclude_category_ids))
116+
SQL
117+
end
116118
end
117119
.map { |r| [r.topic_id, r.distance] }
118120
end

0 commit comments

Comments
 (0)