Skip to content

Commit

Permalink
Do not fail to process all case close reminders if one fails (#3847)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvilanova authored Oct 5, 2023
1 parent 2dfc3aa commit d645320
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/dispatch/case/scheduled.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from datetime import datetime, date
from schedule import every

Expand All @@ -13,6 +15,9 @@
)


log = logging.getLogger(__name__)


@scheduler.add(every(1).day.at("18:00"), name="case-close-reminder")
@timer
@scheduled_project_task
Expand All @@ -23,12 +28,16 @@ def case_close_reminder(db_session: SessionLocal, project: Project):
)

for case in cases:
span = datetime.utcnow() - case.triage_at
q, r = divmod(span.days, 7)
if q >= 1 and date.today().isoweekday() == 1:
# we only send the reminder for cases that have been triaging
# longer than a week and only on Mondays
send_case_close_reminder(case, db_session)
try:
span = datetime.utcnow() - case.triage_at
q, r = divmod(span.days, 7)
if q >= 1 and date.today().isoweekday() == 1:
# we only send the reminder for cases that have been triaging
# longer than a week and only on Mondays
send_case_close_reminder(case, db_session)
except Exception as e:
# if one fails we don't want all to fail
log.exception(e)


@scheduler.add(every(1).day.at("18:00"), name="case-triage-reminder")
Expand Down

0 comments on commit d645320

Please sign in to comment.