Skip to content

Commit

Permalink
Merge remote-tracking branch 'adrien/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalfox committed May 20, 2024
2 parents e02f5d0 + c253594 commit dfde9ec
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ async def check_user_is_declared(update, context):
def outside_business_hours():
"""Don't bother people outside business hours"""
now = datetime.now()
return now.weekday() in (5, 6) or now.hour < 9 or now.hour > 19
today = date.today()
holiday_today = Holiday.objects.filter(day__contains=today)
return now.weekday() in (5, 6) or now.hour < 9 or now.hour > 19 or holiday_today.count() > 0


@db_sync_to_async
Expand All @@ -60,10 +62,6 @@ def get_consultants():
@db_sync_to_async
def time_to_declare(consultant):
today = date.today()
holidays = Holiday.objects.all()
if today.weekday() < 5 and today not in holidays:
declared = Timesheet.objects.filter(consultant=consultant, working_date=today).aggregate(Sum("charge"))[
"charge__sum"] or 0
return 1 - declared
else:
return 0
declared = Timesheet.objects.filter(consultant=consultant, working_date=today).aggregate(Sum("charge"))[
"charge__sum"] or 0
return 1 - declared

0 comments on commit dfde9ec

Please sign in to comment.