Skip to content

Commit 6cbc369

Browse files
committed
fix code to properly be async compliant
1 parent dfde9ec commit 6cbc369

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

bot/pydici_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
async def alert_consultant(context):
5858
"""Randomly alert consultant about important stuff to do"""
59-
if outside_business_hours():
59+
if await outside_business_hours():
6060
return
6161

6262
consultants = await get_consultants()
@@ -89,7 +89,7 @@ async def alert_consultant(context):
8989

9090
async def call_for_timesheet(context):
9191
"""If needed, remind people to declare timesheet of current day"""
92-
if outside_business_hours():
92+
if await outside_business_hours():
9393
return
9494
msg = _("""Hope the day was fine. Time to declare your timesheet no? Just click /time""")
9595

bot/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ async def check_user_is_declared(update, context):
4444
return None
4545

4646

47+
@db_sync_to_async
4748
def outside_business_hours():
4849
"""Don't bother people outside business hours"""
4950
now = datetime.now()
5051
today = date.today()
51-
holiday_today = Holiday.objects.filter(day__contains=today)
52+
holiday_today = Holiday.objects.filter(day=today)
5253
return now.weekday() in (5, 6) or now.hour < 9 or now.hour > 19 or holiday_today.count() > 0
5354

5455

0 commit comments

Comments
 (0)