Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
13 changes: 0 additions & 13 deletions src/dispatch/entity_type/flows.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
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

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,
Expand Down Expand Up @@ -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
12 changes: 12 additions & 0 deletions src/dispatch/entity_type/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,6 +20,7 @@
from .flows import recalculate_entity_flow
from .service import create, delete, get, update

log = logging.getLogger(__name__)
router = APIRouter()


Expand Down Expand Up @@ -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_instances[0].case,
)
except Exception as e:
log.warning(f"Failed to send entity update notification: {e}")

return updated_signal_instances


Expand Down
Loading