Class: Api::V5::SearchesController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::V5::SearchesController
- Defined in:
- app/controllers/api/v5/searches_controller.rb
Overview
typed: ignore frozen_string_literal: true
Constant Summary
Constants inherited from BaseController
BaseController::CACHE_NAMESPACE, BaseController::INTERNAL_SERVER_ERROR_MESSAGE, BaseController::ResponseSchema
Instance Method Summary collapse
Methods inherited from BaseController
Methods included from LogrageCustomLogger
Methods included from ResponseCacheConcern
Instance Method Details
#suggest ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/api/v5/searches_controller.rb', line 5 def suggest suggests = fetch_suggestions cache_key = "#{self.class}:suggest:#{CityHash.hash32([I18n.locale, suggests.cache_key])}" my_response_cache cache_key, :json, public: true do grouped_suggests = suggests.order(rank: :asc).group_by(&:suggestion_type) promotions = grouped_suggests['promotion'] || [] interestings = grouped_suggests['interesting'] || [] restaurants = suggests.order(rank: :asc).group_by(&:suggestion_type)['outlet'] || [] promotions_data = build_promotions_data(promotions) interestings_data = build_interestings_data(interestings) restaurants_data = build_restaurants_data(restaurants) { data: { promotions: promotions_data, interestings: interestings_data, restaurants: restaurants_data, }, success: true, message: nil, } end set_status_header(true) end |