Files
danbooru/app/controllers/autocomplete_controller.rb
evazion a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00

20 lines
614 B
Ruby

# frozen_string_literal: true
class AutocompleteController < ApplicationController
respond_to :xml, :json
def index
@query = params.dig(:search, :query)
@type = params.dig(:search, :type)
@limit = params.fetch(:limit, 10).to_i
@autocomplete = AutocompleteService.new(@query, @type, current_user: CurrentUser.user, limit: @limit)
@results = @autocomplete.autocomplete_results
@expires_in = @autocomplete.cache_duration
@public = @autocomplete.cache_publicly?
expires_in @expires_in, public: @public unless response.cache_control.present?
respond_with(@results)
end
end