Skip to content

Commit

Permalink
Updates notes filtering to search description too
Browse files Browse the repository at this point in the history
Updates notes filtering to search for query text in both note comments and note's description.
  • Loading branch information
nenad-vujicic committed Feb 7, 2025
1 parent 03d90fd commit e8a983a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/api/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ def search
end

# Add any text filter
@notes = @notes.joins(:comments).where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?)", params[:q]) if params[:q]
if params[:q]
@notes = @notes.joins(:comments).where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?) OR to_tsvector('english', notes.description) @@ plainto_tsquery('english', ?)", params[:q], params[:q])
end

# Add any date filter
if params[:from]
Expand Down

0 comments on commit e8a983a

Please sign in to comment.