Migration done
This commit is contained in:
@@ -253,7 +253,8 @@ class ConversionService:
|
||||
# Load all reservations with their hashed customers in one query
|
||||
from sqlalchemy.orm import selectinload
|
||||
query = select(Reservation).options(
|
||||
selectinload(Reservation.customer).selectinload(Customer.hashed_version)
|
||||
selectinload(Reservation.customer).selectinload(Customer.hashed_version),
|
||||
selectinload(Reservation.hashed_customer)
|
||||
)
|
||||
result = await session.execute(query)
|
||||
reservations = result.scalars().all()
|
||||
@@ -265,9 +266,11 @@ class ConversionService:
|
||||
hotel_code = reservation.hotel_code
|
||||
if hotel_code not in self._reservation_cache:
|
||||
self._reservation_cache[hotel_code] = []
|
||||
# Cache the hashed customer instead of raw customer
|
||||
# Cache the hashed customer - prefer direct relationship, fall back to customer relationship
|
||||
hashed_customer = None
|
||||
if reservation.customer and reservation.customer.hashed_version:
|
||||
if reservation.hashed_customer:
|
||||
hashed_customer = reservation.hashed_customer
|
||||
elif reservation.customer and reservation.customer.hashed_version:
|
||||
hashed_customer = reservation.customer.hashed_version
|
||||
self._reservation_cache[hotel_code].append(
|
||||
(reservation, hashed_customer)
|
||||
|
||||
Reference in New Issue
Block a user