Class: PartnerService::Reservations::MetricsService
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- PartnerService::Reservations::MetricsService
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/services/partner_service/reservations/metrics_service.rb
Instance Attribute Summary
Attributes inherited from ApplicationService
Instance Method Summary collapse
-
#initialize(start_date, end_date, restaurant_ids) ⇒ MetricsService
constructor
A new instance of MetricsService.
- #reservations ⇒ Object
- #total_confirm_bookings ⇒ Object
- #total_covers_bookings ⇒ Object
Methods inherited from ApplicationService
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
#reservations ⇒ Object
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_bookings ⇒ Object
23 24 25 |
# File 'app/services/partner_service/reservations/metrics_service.rb', line 23 def total_confirm_bookings reservations.size end |
#total_covers_bookings ⇒ Object
27 28 29 |
# File 'app/services/partner_service/reservations/metrics_service.rb', line 27 def total_covers_bookings reservations.sum(:party_size) end |