side bar search fixing

1) change the search results limit to 40
2) fix band search sql
This commit is contained in:
Nuwan 2023-03-17 10:15:34 +05:30
parent 76c56612cf
commit 599e650d57
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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