Class: Api::Partner::V1::BenchmarkController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::Partner::V1::BenchmarkController
- Defined in:
- app/controllers/api/partner/v1/benchmark_controller.rb
Overview
Controller for benchmark data API Provides performance comparison data for restaurants against competitors and tags
Instance Method Summary collapse
-
#index ⇒ JSON
GET /api/partner/v1/benchmark.
Methods inherited from BaseController
#default_restaurant, #identity_cache_memoization, #render_unauthorize_action, #restaurants, #set_options
Methods included from LogrageCustomLogger
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Methods included from ResponseCacheConcern
Instance Method Details
#index ⇒ JSON
GET /api/partner/v1/benchmark
Query Parameters:
-
data_view_type (required): 'monthly' or 'weekly'
-
data_type (required): 'all', 'tags', or 'competitor'
-
For monthly view:
-
start_month (required): YYYY-MM format
-
end_month (required): YYYY-MM format
-
-
For weekly view:
-
start_date (required): YYYY-MM-DD format
-
end_date (required): YYYY-MM-DD format
-
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/api/partner/v1/benchmark_controller.rb', line 24 def index return unless validate_params! service = PartnerService::Benchmark::CalculateService.new( restaurant: current_restaurant, restaurants: current_staff.restaurants, data_view_type: params[:data_view_type], data_type: params[:data_type], start_date: params[:start_date], end_date: params[:end_date], start_month: params[:start_month], end_month: params[:end_month], ) if service.valid? data = service.call render json: { success: true, data: data } else render json: { success: false, message: service. }, status: :bad_request end end |