def notify_restaurant_owners_about_positive_past_customer_task(customer_id): reservations = ReservationManager.retrieve_by_customer_id_in_last_14_days( customer_id) for reservation in reservations: restaurant = reservation.restaurant owner = restaurant.owner notification = Notification(owner.id, customer_id, restaurant.id, reservation.start_time) NotificationManager.create_notification(notification=notification)
def __retrieve_by_customer_id_in_last_14_days(message): from gooutsafe.dao.reservation_manager import ReservationManager reservations = ReservationManager.retrieve_by_customer_id_in_last_14_days( message['customer_id']) reservations = [ reservation.serialize() for reservation in reservations ] return reservations
def notify_customers_about_positive_contact_task(customer_id): reservations = ReservationManager.retrieve_by_customer_id_in_last_14_days( customer_id) for reservation in reservations: contact_reservations = ReservationManager.retrieve_all_contact_reservation_by_id( reservation.id) for contact_reservation in contact_reservations: restaurant = contact_reservation.restaurant notification = Notification(contact_reservation.user_id, customer_id, restaurant.id, reservation.start_time) NotificationManager.create_notification(notification=notification)