]> git.openstreetmap.org Git - rails.git/commitdiff
Updates notes filtering to search description too
authorNenad Vujicic <nenadus@gmail.com>
Fri, 17 Jan 2025 17:53:05 +0000 (18:53 +0100)
committerNenad Vujicic <nenadus@gmail.com>
Wed, 12 Feb 2025 17:22:50 +0000 (18:22 +0100)
Updates notes filtering to search for query text in both note comments and note's description.

app/controllers/api/notes_controller.rb

index eca0728b65700d90d7ea2f38126c9e06fe961d7c..f6d6dede9b0c76f03219a42e854273266d82db8e 100644 (file)
@@ -263,7 +263,9 @@ module Api
       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]