2017-03-22 03:32:27 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V1::SearchController < ApiController
|
2017-05-31 04:11:54 +03:00
|
|
|
RESULTS_LIMIT = 5
|
|
|
|
|
2017-03-22 03:32:27 +02:00
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def index
|
2017-05-31 04:11:54 +03:00
|
|
|
@search = OpenStruct.new(search_results)
|
|
|
|
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 03:32:27 +02:00
|
|
|
end
|
|
|
|
end
|