|
@@ -1,6 +1,9 @@
|
|
|
|
|
+import logging
|
|
|
from datetime import date
|
|
from datetime import date
|
|
|
|
|
|
|
|
from room_cal.pricing import CalPrice
|
|
from room_cal.pricing import CalPrice
|
|
|
|
|
+
|
|
|
|
|
+_log = logging.getLogger(__name__)
|
|
|
from room_cal.closed import Closed, ClosedData
|
|
from room_cal.closed import Closed, ClosedData
|
|
|
from room_cal.discount import Discount, DiscountData, DiscountType
|
|
from room_cal.discount import Discount, DiscountData, DiscountType
|
|
|
from room_cal.reservations import Reservation
|
|
from room_cal.reservations import Reservation
|
|
@@ -22,9 +25,9 @@ async def refresh_prices(start: date, end: date) -> None:
|
|
|
if base is None:
|
|
if base is None:
|
|
|
continue
|
|
continue
|
|
|
await cal.set(d, base, existing=e, discount_rec=discount_by_date.get(d))
|
|
await cal.set(d, base, existing=e, discount_rec=discount_by_date.get(d))
|
|
|
- print(f" price {d}: ${base}")
|
|
|
|
|
|
|
+ _log.debug("price %s: $%s", d, base)
|
|
|
found += 1
|
|
found += 1
|
|
|
- print(f" {found} price event(s) refreshed")
|
|
|
|
|
|
|
+ _log.info("%d price event(s) refreshed", found)
|
|
|
|
|
|
|
|
|
|
|
|
|
async def refresh_closed(start: date, end: date) -> None:
|
|
async def refresh_closed(start: date, end: date) -> None:
|
|
@@ -43,9 +46,9 @@ async def refresh_closed(start: date, end: date) -> None:
|
|
|
if not services:
|
|
if not services:
|
|
|
continue
|
|
continue
|
|
|
await closed.set(d, ClosedData(services=services, source=source), existing=e)
|
|
await closed.set(d, ClosedData(services=services, source=source), existing=e)
|
|
|
- print(f" closed {d}: {', '.join(services)}")
|
|
|
|
|
|
|
+ _log.debug("closed %s: %s", d, ', '.join(services))
|
|
|
found += 1
|
|
found += 1
|
|
|
- print(f" {found} closed event(s) refreshed")
|
|
|
|
|
|
|
+ _log.info("%d closed event(s) refreshed", found)
|
|
|
|
|
|
|
|
|
|
|
|
|
async def refresh_discounts(start: date, end: date) -> None:
|
|
async def refresh_discounts(start: date, end: date) -> None:
|
|
@@ -65,9 +68,9 @@ async def refresh_discounts(start: date, end: date) -> None:
|
|
|
if dtype is None or value is None:
|
|
if dtype is None or value is None:
|
|
|
continue
|
|
continue
|
|
|
await discount.set(d, DiscountData(type=DiscountType(dtype), value=value, source=source), existing=e)
|
|
await discount.set(d, DiscountData(type=DiscountType(dtype), value=value, source=source), existing=e)
|
|
|
- print(f" discount {d}: {dtype} {value}")
|
|
|
|
|
|
|
+ _log.debug("discount %s: %s %s", d, dtype, value)
|
|
|
found += 1
|
|
found += 1
|
|
|
- print(f" {found} discount event(s) refreshed")
|
|
|
|
|
|
|
+ _log.info("%d discount event(s) refreshed", found)
|
|
|
|
|
|
|
|
|
|
|
|
|
async def refresh_reservations(start: date, end: date) -> None:
|
|
async def refresh_reservations(start: date, end: date) -> None:
|
|
@@ -86,9 +89,9 @@ async def refresh_reservations(start: date, end: date) -> None:
|
|
|
**xd,
|
|
**xd,
|
|
|
}
|
|
}
|
|
|
await reservations.set(data)
|
|
await reservations.set(data)
|
|
|
- print(f" reservation {checkin_date} – {checkout_date}: {xd.get('guest_name', '')}")
|
|
|
|
|
|
|
+ _log.debug("reservation %s – %s: %s", checkin_date, checkout_date, xd.get('guest_name', ''))
|
|
|
found += 1
|
|
found += 1
|
|
|
- print(f" {found} reservation(s) refreshed")
|
|
|
|
|
|
|
+ _log.info("%d reservation(s) refreshed", found)
|
|
|
|
|
|
|
|
|
|
|
|
|
async def refresh_rules(start: date, end: date) -> None:
|
|
async def refresh_rules(start: date, end: date) -> None:
|
|
@@ -96,9 +99,9 @@ async def refresh_rules(start: date, end: date) -> None:
|
|
|
results = await apply_rules(start, end)
|
|
results = await apply_rules(start, end)
|
|
|
for name, dates in results.items():
|
|
for name, dates in results.items():
|
|
|
for d in dates:
|
|
for d in dates:
|
|
|
- print(f" rule {name}: {d}")
|
|
|
|
|
|
|
+ _log.debug("rule %s: %s", name, d)
|
|
|
total = sum(len(v) for v in results.values())
|
|
total = sum(len(v) for v in results.values())
|
|
|
- print(f" {total} rule event(s) refreshed")
|
|
|
|
|
|
|
+ _log.info("%d rule event(s) refreshed", total)
|
|
|
|
|
|
|
|
|
|
|
|
|
async def local_refresh(start: date, end: date) -> None:
|
|
async def local_refresh(start: date, end: date) -> None:
|