Migration done

This commit is contained in:
Jonas Linter
2025-11-19 15:01:16 +01:00
parent 6c46c566ed
commit d88a53327f
4 changed files with 87 additions and 4 deletions

View File

@@ -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)