Module: SeatAvailability

Defined in:
lib/seat_availability.rb

Overview

typed: ignore frozen_string_literal: true

Class Method Summary collapse

Class Method Details

.last_minute_booking?(restaurant_id, date, start_time, service_type = nil) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/seat_availability.rb', line 5

def last_minute_booking?(restaurant_id, date, start_time, service_type=nil)
  restaurant = Restaurant.fetch restaurant_id
  time = Time.use_zone restaurant.time_zone do
    Time.zone.parse("#{date} #{start_time}")
  end
  now = Time.now_in_tz(restaurant.time_zone)

  return true if ((time - now).to_i / 60).abs <= (restaurant.determine_min_booking_time(service_type: service_type) - AdminSetting.booking_buffer_time_in_minute.to_i)

  false
end