Create scopes for filtering comment by user or system
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user