Skip to content

Commit

Permalink
Lower the log level when notification are without a target for cases …
Browse files Browse the repository at this point in the history
…closed unassigned & unstarted

Cases are commonly closed unassigned (i.e. without an assigned paralegal or
lawyer) & unstarted (i.e. the previous case stage is "UNSTARTED") for a variety
of valid reasons. See https://linear.app/anika-legal/issue/TEC-1387/ for more
details.

Prior to this change we would log an error when users closed a case unassigned
& unstarted which would ultimately trigger the creation of an issue in our
error monitoring system (Sentry).

In these cases we now log a message at the info level as this is a common &
valid action that does not represent an error.
  • Loading branch information
luca-vari committed Oct 31, 2024
1 parent f7d0bbb commit 19cf3ba
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions app/notify/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.dispatch import receiver
from django_q.tasks import async_task

from core.models import Issue
from core.models.issue import Issue, CaseStage
from notify.models import Notification, NotifyEvent, NotifyTarget, NotifyChannel
from slack.services import (
send_slack_direct_message,
Expand Down Expand Up @@ -55,11 +55,18 @@ def on_issue_stage_change(issue_pk, old_stage: str, new_stage: str):
email = issue.lawyer and issue.lawyer.email

if not email:
logger.error(
"No matching email found for Notification[%s] and Issue[%s]",
notification.pk,
issue_pk,
)
if old_stage == CaseStage.UNSTARTED and new_stage == CaseStage.CLOSED:
logger.info(
"No notification target for Notification[%s] as Issue[%s] closed unassigned and unstarted",
notification.pk,
issue_pk,
)
else:
logger.error(
"No notification target found for Notification[%s] and Issue[%s]",
notification.pk,
issue_pk,
)
continue

logger.info(
Expand Down

0 comments on commit 19cf3ba

Please sign in to comment.