From: ENT8R Date: Tue, 9 Oct 2018 12:37:55 +0000 (+0200) Subject: Fix an issue where the query did not work if a display name or an id was specified X-Git-Tag: live~2818^2~3 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3cdf4f3686aca9054e85d61ac62acaa98b16c42b Fix an issue where the query did not work if a display name or an id was specified --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index ba2df3680..27c3f4f83 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -274,8 +274,12 @@ class NotesController < ApplicationController # Filter by a given string if params[:q] - # TODO: why doesn't this work if we want to filter the notes of a given user? - @notes = @notes.joins(:comments).where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?)", params[:q]) unless params[:display_name] || params[:id] + @notes = @notes.joins(:comments) + if @user + @notes = @notes.where("to_tsvector('english', comments_notes.body) @@ plainto_tsquery('english', ?)", params[:q]) + else + @notes = @notes.where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?)", params[:q]) + end end # Filter by a given start date and an optional end date