[StaffNotes] Fix body searching (#654)

This commit is contained in:
Donovan Daniels 2024-06-27 18:17:40 -05:00 committed by GitHub
parent 715ea9bddb
commit 4f61a94504
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -6,8 +6,8 @@ module Admin
respond_to :html
def index
@user = User.where('id = ?', params[:user_id]).first
@notes = StaffNote.search(search_params.merge({user_id: params[:user_id]})).includes(:user, :creator).paginate(params[:page])
@user = User.find_by(id: params[:user_id])
@notes = StaffNote.search(search_params.merge({ user_id: params[:user_id] })).includes(:user, :creator).paginate(params[:page], limit: params[:limit])
respond_with(@notes)
end
@ -30,8 +30,12 @@ module Admin
private
def search_params
permit_search_params(%i[creator_id creator_name user_id user_name resolved body_matches without_system_user])
end
def note_params
params.fetch(:staff_note, {}).permit([:body])
params.fetch(:staff_note, {}).permit(%i[body])
end
end
end

View File

@ -8,10 +8,8 @@ class StaffNote < ApplicationRecord
def search(params)
q = super
if params[:resolved]
q = q.attribute_matches(:resolved, params[:resolved])
end
q = q.attribute_matches(:resolved, params[:resolved])
q = q.attribute_matches(:body, params[:body_matches])
q = q.where_user(:user_id, :user, params)
q = q.where_user(:creator_id, :creator, params)