Skip to content

Commit 7b844b5

Browse files
committed
remove hardcoded date during testing and fix "today"
1 parent de9c098 commit 7b844b5

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

core/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,13 @@ async def handle_daily_emails(app):
235235
delta = (next_email - datetime.now()).seconds
236236
await asyncio.sleep(delta)
237237

238+
today = date.today() # next day after sleeping
238239
if today.weekday() in (5, 6):
239240
# Could be here if the func was called after the time on Friday
240241
return app.add_task(handle_daily_emails)
241242

242243

243-
today_info = await get_school_week(date(2020, 11, 16), date(2020, 9, 8), week=False)
244+
today_info = await get_school_week(today, date(2020, 9, 8), week=False)
244245
if today_info is None:
245246
# No school
246247
await asyncio.sleep(1)
@@ -252,11 +253,11 @@ async def handle_daily_emails(app):
252253
messages = []
253254
for email in emails:
254255
msg = EmailMessage()
255-
msg['Subject'] = f"GCHS Daily Email Notification for {date.today().strftime('%m/%d/%Y')}"
256+
msg['Subject'] = f"GCHS Daily Email Notification for {today.strftime('%m/%d/%Y')}"
256257
msg['From'] = app.config.CUSTOM_EMAIL
257258
msg['To'] = email
258259
body = MIMEText(
259-
f"Today, {date.today().strftime('%m/%d/%Y')}, is a {today_info['cohort'].title()} {today_info['day']} day. <br><br>"
260+
f"Today, {today.strftime('%m/%d/%Y')}, is a {today_info['cohort'].title()} {today_info['day']} day. <br><br>"
260261
f"Click <a href=\"http{'s' if not app.config.DEV else ''}://{app.config.DOMAIN}"
261262
f"/schoolweek/unsubscribe/{msg['To']}\">here</a> to unsubscribe.", 'html')
262263

0 commit comments

Comments
 (0)