Class: PartnerService::Reservations::MetricsService

Inherits:
ApplicationService show all
Includes:
ElasticAPM::SpanHelpers
Defined in:
app/services/partner_service/reservations/metrics_service.rb

Instance Attribute Summary

Attributes inherited from ApplicationService

#object

Instance Method Summary collapse

Methods inherited from ApplicationService

#execute, #execute!

Constructor Details

#initialize(start_date, end_date, restaurant_ids) ⇒ MetricsService

Returns a new instance of MetricsService.



8
9
10
11
12
# File 'app/services/partner_service/reservations/metrics_service.rb', line 8

def initialize(start_date, end_date, restaurant_ids)
  @start_date = start_date
  @end_date = end_date
  @restaurant_ids = restaurant_ids
end

Instance Method Details

#reservationsObject



14
15
16
17
18
19
20
21
# File 'app/services/partner_service/reservations/metrics_service.rb', line 14

def reservations
  Reservation.where(restaurant_id: @restaurant_ids).
    where(active: true, no_show: false, is_temporary: false, for_locking_system: false).
    where('date between ? and ?', @start_date, @end_date).
    joins(:property).
    includes(:property).
    where.not(reservation_properties: { package: nil })
end

#total_confirm_bookingsObject



23
24
25
# File 'app/services/partner_service/reservations/metrics_service.rb', line 23

def total_confirm_bookings
  reservations.size
end

#total_covers_bookingsObject



27
28
29
# File 'app/services/partner_service/reservations/metrics_service.rb', line 27

def total_covers_bookings
  reservations.sum(:party_size)
end