Skip to content

Commit 7f23b2b

Browse files
committed
Avoid division by zero
1 parent 5a4c23b commit 7f23b2b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ def complete_task(task_id) -> Response: # complete task from task id
240240
).days # calculate the number of days until the task is due
241241
if days_to_due > 0: # if task due date is after today
242242
due_multiplier: float = 1 + 1 / (
243-
days_to_due + 1
243+
max(1, days_to_due + 1)
244244
) # set due multiplier that increases over time when the task is closer to due date
245245
elif (
246246
days_to_due < 0
247247
): # if the task is overdue (current date is after task due date)
248248
due_multiplier = -2 / (
249-
days_to_due - 1
249+
min(-1, days_to_due - 1)
250250
) # set due multiplier that decreases over time when the task is overdue
251251
elif days_to_due == 0: # if task due date is today
252252
next_midnight: datetime = datetime.combine(

0 commit comments

Comments
 (0)