fixing timedelta
This commit is contained in:
parent
9486225e8b
commit
3eaff8dccf
2 changed files with 2 additions and 5 deletions
|
@ -9,12 +9,8 @@ class EventNotifyerService:
|
|||
pass
|
||||
|
||||
def notifyUpcommingEvents():
|
||||
# this method will get the upcoming events from the event service
|
||||
# foreach event, locate the users with the same location as the event but not the users that already been notifyed about the event
|
||||
# foreach user, append to UserEventAssociation table that the user is been notified about the event
|
||||
events = EventService.get_upcoming_events()
|
||||
for event in events:
|
||||
# locate users with the same location as the event but not the users that already been notifyed about the event (users with UserEventAssociation)
|
||||
users = UserService.get_users_with_same_location_but_not_been_notifyed(event['location'])
|
||||
if not users:
|
||||
print("No user to notify")
|
||||
|
|
|
@ -22,9 +22,10 @@ class EventService:
|
|||
|
||||
@staticmethod
|
||||
def get_upcoming_events(location=None, sort_by=None):
|
||||
timedelta = datetime.now() + timedelta(minutes=30)
|
||||
query = Event.query.filter(
|
||||
Event.deleted == False,
|
||||
Event.duedate > datetime.now()
|
||||
Event.duedate <= timedelta
|
||||
)
|
||||
if location:
|
||||
query = query.filter(Event.location.ilike(f"%{location}%"))
|
||||
|
|
Loading…
Reference in a new issue