jam-cloud/web/app/controllers/api_search_controller.rb

28 lines
1001 B
Ruby

class ApiSearchController < ApiController
# have to be signed in currently to see this screen
before_filter :api_signed_in_user
respond_to :json
def index
if 1 == params[Search::PARAM_MUSICIAN].to_i || 1 == params[Search::PARAM_BAND].to_i
# puts "================== params #{params.to_s}"
query = params.clone
query[:remote_ip] = request.remote_ip
if 1 == query[Search::PARAM_MUSICIAN].to_i
clientid = query[:clientid]
conn = (clientid ? Connection.where(client_id: clientid, user_id: current_user.id).first : nil)
@search = Search.musician_filter(query, current_user, conn)
else
@search = Search.band_filter(query, current_user)
end
respond_with @search, responder: ApiResponder, :status => 200
elsif 1 == params[Search::PARAM_SESSION_INVITE].to_i
@search = Search.session_invite_search(params[:query], current_user)
else
@search = Search.text_search(params, current_user)
end
end
end