Class: Api::Partner::V1::DashboardsController

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

Instance Method Summary collapse

Methods inherited from BaseController

#default_restaurant, #identity_cache_memoization, #render_unauthorize_action, #restaurants, #set_options

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Methods included from ResponseCacheConcern

#my_response_cache

Instance Method Details

#indexObject



3
4
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
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/api/partner/v1/dashboards_controller.rb', line 3

def index
  type = params.require(:type)
  result = PartnerService::Dashboards::CalculateService.new(restaurants)
  data =
    case type
    when 'pending_bookings'
      { pending_bookings: result.pending_bookings }
    when 'today_bookings'
      { today_bookings: result.today_bookings }
    when 'upcoming_bookings'
      { upcoming_bookings: result.upcoming_bookings }
    when 'this_month_bookings'
      { this_month_bookings: result.this_month_bookings }
    when 'last_month_bookings'
      { last_month_bookings: result.last_month_bookings }
    when 'two_months_before_bookings'
      { two_months_before_bookings: result.two_months_before_bookings }
    when 'package'
      { package: result.package_summary }
    when 'ratings'
      { ratings: result.ratings }
    when 'voucher'
      { voucher: result.voucher_sales }
    when 'current_month_bookings_revenue'
      { current_month_bookings_revenue: result.current_month_bookings_revenue }
    when 'last_month_bookings_revenue'
      { last_month_bookings_revenue: result.last_month_bookings_revenue }
    when 'two_months_before_bookings_revenue'
      { two_months_before_bookings_revenue: result.two_months_before_bookings_revenue }
    when 'last_8_weeks_bookings_revenue'
      { last_8_weeks_bookings_revenue: result.last_8_weeks_bookings_revenue }
    else
      { revenue_chart_id: MongoDbService::Connection::REVENUE_CHART_IDS[:last_30_day] }
    end

  render json: { data: data }
end