|
@@ -60,7 +60,7 @@ async def diff(
|
|
|
_timed('prices', _diff_prices(start_date, end_date, api), timings),
|
|
_timed('prices', _diff_prices(start_date, end_date, api), timings),
|
|
|
_timed('closed', _diff_closed(start_date, end_date, api), timings),
|
|
_timed('closed', _diff_closed(start_date, end_date, api), timings),
|
|
|
_timed('reservations', _diff_reservations(start_date, end_date, api), timings),
|
|
_timed('reservations', _diff_reservations(start_date, end_date, api), timings),
|
|
|
- _timed('double_bookings', _diff_double_bookings(start_date, end_date, api), timings),
|
|
|
|
|
|
|
+ _timed('double_bookings', _diff_double_bookings(start_date, end_date), timings),
|
|
|
_timed('user_cal_closed', _diff_user_cal_closed(start_date, end_date), timings),
|
|
_timed('user_cal_closed', _diff_user_cal_closed(start_date, end_date), timings),
|
|
|
_timed('ical_feeds_closed', _diff_ical_feeds_closed(start_date, end_date), timings),
|
|
_timed('ical_feeds_closed', _diff_ical_feeds_closed(start_date, end_date), timings),
|
|
|
_timed('rule_discounts', _diff_rule_discounts(start_date, end_date), timings),
|
|
_timed('rule_discounts', _diff_rule_discounts(start_date, end_date), timings),
|
|
@@ -251,16 +251,29 @@ async def _diff_reservations(
|
|
|
async def _diff_double_bookings(
|
|
async def _diff_double_bookings(
|
|
|
start_date: date,
|
|
start_date: date,
|
|
|
end_date: date,
|
|
end_date: date,
|
|
|
- api: 'ServiceAPI',
|
|
|
|
|
) -> list[dict]:
|
|
) -> list[dict]:
|
|
|
- """Service API reservations that overlap in date range (double bookings).
|
|
|
|
|
|
|
+ """Local reservation store entries that overlap in date range (double bookings).
|
|
|
|
|
|
|
|
Each row: {'a': {id, guest_name, service, checkin_date, checkout_date},
|
|
Each row: {'a': {id, guest_name, service, checkin_date, checkout_date},
|
|
|
'b': {id, guest_name, service, checkin_date, checkout_date},
|
|
'b': {id, guest_name, service, checkin_date, checkout_date},
|
|
|
'overlap_start', 'overlap_end'}
|
|
'overlap_start', 'overlap_end'}
|
|
|
Sorted by overlap_start.
|
|
Sorted by overlap_start.
|
|
|
"""
|
|
"""
|
|
|
- reservations = await api.get_reservations(start_date, end_date)
|
|
|
|
|
|
|
+ res_cal = Reservation()
|
|
|
|
|
+ cal_events = await res_cal.list(start_date, end_date)
|
|
|
|
|
+ reservations = []
|
|
|
|
|
+ for e in cal_events:
|
|
|
|
|
+ if e.start.date() < start_date:
|
|
|
|
|
+ continue
|
|
|
|
|
+ d = safe_json_loads(e.x_data)
|
|
|
|
|
+ if d and d.get('reservation_id'):
|
|
|
|
|
+ reservations.append({
|
|
|
|
|
+ 'id': d['reservation_id'],
|
|
|
|
|
+ 'guest_name': d.get('guest_name', ''),
|
|
|
|
|
+ 'service': d.get('service', ''),
|
|
|
|
|
+ 'start_date': e.start.date(),
|
|
|
|
|
+ 'end_date': e.end.date(),
|
|
|
|
|
+ })
|
|
|
results: list[dict] = []
|
|
results: list[dict] = []
|
|
|
for i, a in enumerate(reservations):
|
|
for i, a in enumerate(reservations):
|
|
|
for b in reservations[i + 1:]:
|
|
for b in reservations[i + 1:]:
|