In the BookingService class, located in /path/to/repo/chapters/09/src/booksomeplace/domain/booking.py, we define a method, getTrendData(), which returns historic and future data based on query parameters. Next, we formulate the base query filter, as well as the desired projection and sort criteria:
query = {'bookingInfo.paymentStatus':'confirmed'}
projection = {'bookingInfo.arrivalDate':1,'totalPrice':1}
sort = [('bookingInfo.arrivalDate',1)]
We now build onto the query dictionary by checking to see whether parameters are set:
if 'trend_city' in params and params['trend_city'] :
query.update({'property.propertyAddr.city':
{'$regex' : '*' + params['trend_city'] + '*' }})
if 'trend_region' in params and params['trend_region'] :
query.update({'property...