[openstreetmap/openstreetmap-website] Enhanced the notes search endpoint (#1955)

Tom Hughes notifications at github.com
Wed Oct 10 16:58:26 UTC 2018


tomhughes commented on this pull request.



> -    @notes = @notes.joins(:comments).where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?)", params[:q])
+    if @user
+      @notes = @user.notes
+      @notes = closed_condition(@notes)
+    elsif params[:display_name] || params[:id]
+      # Return an error message because obviously the user could not be found
+      raise OSM::APIBadUserInput, "The user could not be found"
+    else
+      @notes = closed_condition(Note.all)
+    end
+
+    # Filter by a given string
+    if params[:q]
+      @notes = @notes.joins(:comments)
+      @notes = if @user
+                 @notes.where("to_tsvector('english', comments_notes.body) @@ plainto_tsquery('english', ?)", params[:q])

Sorry, that's what I meant. I was playing with with various things and copied the wrong one - you don't need `.id` on the user object though as rails will do that anyway.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/1955#discussion_r224160834
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20181010/59a10e0f/attachment.html>


More information about the rails-dev mailing list