Class: Api::V5::CuisinesController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::V5::CuisinesController
- Defined in:
- app/controllers/api/v5/cuisines_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
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/api/v5/cuisines_controller.rb', line 5 def index page = params.fetch(:page, {}) filter = Api::V5::CuisinesFilter.new.init_default city_id = params[:city_id] ids = params[:cuisine_ids] filter.by_ids(ids) if ids.present? filter.by_city_id(city_id) if city_id.present? sort_by = params.fetch(:sort, 'total_restaurants_desc') cache_key = "#{CACHE_NAMESPACE}:#{self.class}:#{I18n.locale}:#{RestaurantTag.cuisines_cache_key}:index#{sort_by}#{city_id}#{ids}" my_response_cache(cache_key, :json, public: true) do filter.sort_by(sort_by) filter.page_number(page[:number]).per_page(page[:size]) = {} filter.as_json(serialization_context, minor_version_param, ).merge(success: true, message: nil) end set_status_header(true) end |