|
@@ -20,9 +20,6 @@ if TYPE_CHECKING:
|
|
|
|
|
|
|
|
ACTION_SPEC = ('diff', [])
|
|
ACTION_SPEC = ('diff', [])
|
|
|
|
|
|
|
|
-_PRICE_PREFIX = 'Price: $'
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
def _clamp_future(start_date: date) -> date:
|
|
def _clamp_future(start_date: date) -> date:
|
|
|
"""Past dates are not compared — only reservation data has historical value."""
|
|
"""Past dates are not compared — only reservation data has historical value."""
|
|
|
return max(start_date, local_today())
|
|
return max(start_date, local_today())
|
|
@@ -97,12 +94,8 @@ async def _diff_prices(
|
|
|
if start_date > end_date:
|
|
if start_date > end_date:
|
|
|
return []
|
|
return []
|
|
|
|
|
|
|
|
- from datetime import datetime
|
|
|
|
|
- backend = get_backend()
|
|
|
|
|
- start_dt = datetime(start_date.year, start_date.month, start_date.day)
|
|
|
|
|
- end_dt = datetime(end_date.year, end_date.month, end_date.day) + timedelta(days=1)
|
|
|
|
|
- events, api_prices, res_events = await asyncio.gather(
|
|
|
|
|
- backend.fetch_range(start_dt, end_dt),
|
|
|
|
|
|
|
+ price_events, api_prices, res_events = await asyncio.gather(
|
|
|
|
|
+ CalPrice().list(start_date, end_date),
|
|
|
api.get_prices_range(start_date, end_date),
|
|
api.get_prices_range(start_date, end_date),
|
|
|
Reservation().list(start_date, end_date),
|
|
Reservation().list(start_date, end_date),
|
|
|
)
|
|
)
|
|
@@ -111,7 +104,7 @@ async def _diff_prices(
|
|
|
|
|
|
|
|
svc_keys = _services()
|
|
svc_keys = _services()
|
|
|
cal_prices: dict[str, PriceData] = {}
|
|
cal_prices: dict[str, PriceData] = {}
|
|
|
- for e in filter_events(events, _PRICE_PREFIX, all_day=True):
|
|
|
|
|
|
|
+ for e in price_events:
|
|
|
d = safe_json_loads(e.x_data)
|
|
d = safe_json_loads(e.x_data)
|
|
|
if d is not None:
|
|
if d is not None:
|
|
|
cal_prices[e.start.date().isoformat()] = PriceData.from_dict(d, svc_keys)
|
|
cal_prices[e.start.date().isoformat()] = PriceData.from_dict(d, svc_keys)
|