Skip to content

Commit

Permalink
Merge pull request #83 from jonathanjma/Zach/SchedulerMod
Browse files Browse the repository at this point in the history
Update scheduler
  • Loading branch information
jonathanjma authored Feb 25, 2024
2 parents eb3d9eb + 1919c97 commit 00d60a5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions happiness-backend/jobs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,16 @@ def queue_send_notification_emails():
Adds all notification email requests to the redis queue
A user will be a part of a notification email request if they satisfy the following conditions:
Has a setting with the key "notify"
The value of the setting is a 24-hour time with hours and minutes in UTC.
The value of the setting is a 24-hour time with hours and minutes, MUST BE IN UTC
It includes the user's timezone with a space after
See https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568
This timezone is used to make sure that they are notified based on if they are missing entries in their timezone
For list of valid timezones see https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568
The UTC time they provided is used for the actual notification time
They have less than 6 Happiness entries from yesterday to 1 week before today
"""
current_time = str(datetime.now().time().strftime("%H:%M"))
current_time = str(datetime.utcnow().time().strftime("%H:%M"))

to_notify = Setting.query.filter(Setting.value.startswith(str(current_time)), Setting.key == "notify",
Setting.enabled.is_(True)).all()
Expand Down

0 comments on commit 00d60a5

Please sign in to comment.