From 5335d7716d74453500ebba7f3a002835410658e3 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Mon, 9 Jun 2025 16:24:54 -0700 Subject: [PATCH 1/3] fix(entity_type): send channel notification once --- src/dispatch/entity_type/flows.py | 13 ------------- src/dispatch/entity_type/views.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/dispatch/entity_type/flows.py b/src/dispatch/entity_type/flows.py index 2018a2d530e5..c008d72f2785 100644 --- a/src/dispatch/entity_type/flows.py +++ b/src/dispatch/entity_type/flows.py @@ -1,6 +1,4 @@ -import logging from sqlalchemy.orm import Session -from dispatch.case.messaging import send_entity_update_notification from dispatch.entity_type.models import EntityScopeEnum from dispatch.signal.models import SignalInstance from dispatch.entity_type import service as entity_type_service @@ -8,8 +6,6 @@ from dispatch.entity_type.models import EntityType from dispatch.entity import service as entity_service -log = logging.getLogger(__file__) - def recalculate_entity_flow( db_session: Session, @@ -38,13 +34,4 @@ def recalculate_entity_flow( signal_instance.entities = entities db_session.commit() - try: - send_entity_update_notification( - db_session=db_session, - entity_type=entity_type, - case=signal_instance.case, - ) - except Exception as e: - log.warning(f"Failed to send entity update notification: {e}") - return signal_instance diff --git a/src/dispatch/entity_type/views.py b/src/dispatch/entity_type/views.py index 162600fbf88c..496c4fc58ba5 100644 --- a/src/dispatch/entity_type/views.py +++ b/src/dispatch/entity_type/views.py @@ -1,8 +1,10 @@ +import logging from fastapi import APIRouter, HTTPException, status from pydantic import ValidationError from sqlalchemy.exc import IntegrityError +from dispatch.case.messaging import send_entity_update_notification from dispatch.case.service import get as get_case from dispatch.database.core import DbSession from dispatch.database.service import CommonParameters, search_filter_sort_paginate @@ -18,6 +20,7 @@ from .flows import recalculate_entity_flow from .service import create, delete, get, update +log = logging.getLogger(__file__) router = APIRouter() @@ -113,6 +116,15 @@ def recalculate(db_session: DbSession, entity_type_id: PrimaryKey, case_id: Prim ) updated_signal_instances.append(updated_signal_instance) + try: + send_entity_update_notification( + db_session=db_session, + entity_type=entity_type, + case=signal_instance[0].case, + ) + except Exception as e: + log.warning(f"Failed to send entity update notification: {e}") + return updated_signal_instances From 969cb94ae81f3ed86dc5846bea54430b5da28e31 Mon Sep 17 00:00:00 2001 From: David Whittaker <84562015+whitdog47@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:16:17 -0700 Subject: [PATCH 2/3] Update src/dispatch/entity_type/views.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: David Whittaker <84562015+whitdog47@users.noreply.github.com> --- src/dispatch/entity_type/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatch/entity_type/views.py b/src/dispatch/entity_type/views.py index 496c4fc58ba5..7f05a486efa2 100644 --- a/src/dispatch/entity_type/views.py +++ b/src/dispatch/entity_type/views.py @@ -20,7 +20,7 @@ from .flows import recalculate_entity_flow from .service import create, delete, get, update -log = logging.getLogger(__file__) +log = logging.getLogger(__name__) router = APIRouter() From 73e2a5b57dc021c829d8a11b9bc6f04ac8e56f01 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Tue, 10 Jun 2025 14:18:45 -0700 Subject: [PATCH 3/3] fixing typo --- src/dispatch/entity_type/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatch/entity_type/views.py b/src/dispatch/entity_type/views.py index 7f05a486efa2..35343a9439e8 100644 --- a/src/dispatch/entity_type/views.py +++ b/src/dispatch/entity_type/views.py @@ -120,7 +120,7 @@ def recalculate(db_session: DbSession, entity_type_id: PrimaryKey, case_id: Prim send_entity_update_notification( db_session=db_session, entity_type=entity_type, - case=signal_instance[0].case, + case=signal_instances[0].case, ) except Exception as e: log.warning(f"Failed to send entity update notification: {e}")