2017-03-22 12:32:27 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-08 04:09:25 +10:00
|
|
|
class Api::V1::SearchController < Api::BaseController
|
2017-05-31 11:11:54 +10:00
|
|
|
RESULTS_LIMIT = 5
|
|
|
|
|
2017-03-22 12:32:27 +11:00
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def index
|
2017-07-07 12:02:06 +10:00
|
|
|
@search = Search.new(search_results)
|
|
|
|
render json: @search, serializer: REST::SearchSerializer
|
2017-05-31 11:11:54 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def search_results
|
|
|
|
SearchService.new.call(
|
|
|
|
params[:q],
|
|
|
|
RESULTS_LIMIT,
|
|
|
|
resolving_search?,
|
|
|
|
current_account
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolving_search?
|
|
|
|
params[:resolve] == 'true'
|
2017-03-22 12:32:27 +11:00
|
|
|
end
|
|
|
|
end
|