From 599e650d570732c59dec5c9ab22092f35f299d15 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Fri, 17 Mar 2023 10:15:34 +0530 Subject: [PATCH] side bar search fixing 1) change the search results limit to 40 2) fix band search sql --- ruby/lib/jam_ruby/models/search.rb | 11 ++++++++--- web/app/controllers/api_search_controller.rb | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ruby/lib/jam_ruby/models/search.rb b/ruby/lib/jam_ruby/models/search.rb index 6a6b8ec35..5993f6841 100644 --- a/ruby/lib/jam_ruby/models/search.rb +++ b/ruby/lib/jam_ruby/models/search.rb @@ -75,7 +75,7 @@ module JamRuby rel = case params[SEARCH_TEXT_TYPE_ID].to_s when 'bands' @search_type = :bands - Band.where(nil) + Band.where(nil).joins(:users) when 'fans' @search_type = :fans User.fans.not_deleted @@ -83,8 +83,13 @@ module JamRuby @search_type = :musicians User.musicians.not_deleted end - - @results = rel.where("(name_tsv @@ to_tsquery('jamenglish', ?))", tsquery).limit(10) + if @search_type == :bands + @results = rel.where("(bands.name_tsv @@ to_tsquery('jamenglish', ?))", tsquery) + else + @results = rel.where("(users.name_tsv @@ to_tsquery('jamenglish', ?))", tsquery) + end + @results = @results.limit(40) + @results = Search.scope_schools_together(@results, user) end diff --git a/web/app/controllers/api_search_controller.rb b/web/app/controllers/api_search_controller.rb index bc150aab4..7f346ff60 100644 --- a/web/app/controllers/api_search_controller.rb +++ b/web/app/controllers/api_search_controller.rb @@ -8,6 +8,7 @@ class ApiSearchController < ApiController include LatencyHelper def index + #debugger if 1 == params[Search::PARAM_MUSICIAN].to_i || 1 == params[Search::PARAM_BAND].to_i query = params.clone query[:remote_ip] = request.remote_ip