def merge_main_hotel_info(self, hotels): hotel_ids = [mapping.main_hotel_id for mapping in hotels] main_hotels = Hotel.get_by_ids(self.db, hotel_ids) for hotel in hotels: for main_hotel in main_hotels: if main_hotel.id == hotel.main_hotel_id: hotel['main_hotel'] = main_hotel.todict() break
def merge_hotels(self, hotel_room): hotel_ids = [hotel['main_hotel_id'] for hotel in hotel_room] self.roomtypes = RoomType.gets_by_hotel_ids(self.db, hotel_ids) self.roomtypes = [roomtype.todict() for roomtype in self.roomtypes] hotels = Hotel.get_by_ids(self.db, hotel_ids) hotel_mapping = {hotel.todict()['id']: hotel.todict() for hotel in hotels} for hotel in hotel_room: if hotel['main_hotel_id'] in hotel_mapping: hotel['main_hotel'] = hotel_mapping[hotel['main_hotel_id']]