Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fail to process all case close reminders if one fails #3847

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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