Create scopes for filtering comment by user or system

This commit is contained in:
Stanko K.R.
2025-08-14 14:32:10 +02:00
parent 221f8434d8
commit 10728e35ef
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -31,9 +31,9 @@ class Ai::ListCommentsTool::Filter < Ai::Tool::Filter
def apply_type_filter(scope)
if filters[:type].casecmp?("system")
scope.where(creator: { role: "system" })
scope.by_system
else
scope.where.not(creator: { role: "system" })
scope.by_user
end
end
end
+2
View File
@@ -9,6 +9,8 @@ class Comment < ApplicationRecord
searchable_by :body, using: :comments_search_index
scope :chronologically, -> { order created_at: :asc, id: :desc }
scope :by_system, -> { joins(:creator).where(creator: { role: "system" }) }
scope :by_user, -> { joins(:creator).where.not(creator: { role: "system" }) }
after_create_commit :watch_card_by_creator