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

30 lines
1.1 KiB
Ruby
Raw Normal View History

class ApiSearchController < ApiController
# have to be signed in currently to see this screen
2012-11-14 05:37:50 +00:00
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
2014-05-29 02:19:50 +00:00
# puts "================== params #{params.to_s}"
2013-11-04 14:47:30 +00:00
query = params.clone
query[:remote_ip] = request.remote_ip
if 1 == query[Search::PARAM_MUSICIAN].to_i
2014-05-29 02:19:50 +00:00
clientid = query[:clientid]
conn = (clientid ? Connection.where(client_id: clientid, user_id: current_user.id).first : nil)
# puts "================== query #{query.inspect}"
@search = Search.musician_filter(query, current_user, conn)
# puts "================== search #{@search.inspect}"
else
@search = Search.band_filter(query, current_user)
end
2013-12-16 18:29:16 +00:00
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)
2013-11-04 14:47:30 +00:00
else
@search = Search.text_search(params, current_user)
2013-11-04 14:47:30 +00:00
end
end
end