Class: Api::Aoa::V1::PackageTypesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/aoa/v1/package_types_controller.rb

Overview

package types

Constant Summary

Constants inherited from BaseController

BaseController::CACHE_NAMESPACE

Instance Method Summary collapse

Methods inherited from BaseController

#identity_cache_memoization

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from ResponseCacheConcern

#my_response_cache

Instance Method Details

#indexObject



9
10
11
12
13
14
15
16
17
# File 'app/controllers/api/aoa/v1/package_types_controller.rb', line 9

def index
  city_id = params[:city_id]
  cache_key = "#{CACHE_NAMESPACE}:#{self.class}:index:#{PackageType.maximum(:updated_at)}:#{city_id}:#{MyLocaleManager.normalize_locale}"
  my_response_cache cache_key, :json, public: true do
    package_types = PackageType.where(active: true).where.not(package_type_code: 'hah')
    package_types = package_types.includes(:cities).joins(:cities).where(cities: { id: city_id }).group(:id) if city_id.present?
    Api::Aoa::V1::PackageTypeSerializer.new(package_types).as_json
  end
end