# this Class is for the scheduler #this class will have a function that locates the upcomming events Using the Event service. from services.EventService import EventService from services.UserService import UserService from models import UserEventAssociation, db class EventNotifyerService: def __init__(self): pass def notifyUpcommingEvents(): events = EventService.get_all_upcomming_events() for event in events: users = UserService.get_users_with_same_location_but_not_been_notifyed(event['location']) if not users: print("No user to notify") continue for user in users: print("Found user to notify:", user) if notify_user(user['email'], event): user_event_association = UserEventAssociation( user_id=user['id'], event_id=event['id'] ) db.session.add(user_event_association) db.session.commit() def notify_user(userEmail, event): try: print("User:", userEmail, "Event:", event) return True except: print("Error printing user and event") return False