Correlator bugfix

This commit is contained in:
Logan
2026-05-25 15:57:59 -04:00
parent adf10244b4
commit 84ab72442f
@@ -233,7 +233,16 @@ async def correlate_call(
# • Substantive → verify via _call_fits_incident before linking.
if talkgroup_id is not None and system_id:
tg_str = str(talkgroup_id)
is_dispatch = _is_dispatch_channel(talkgroup_name)
# talkgroup_name may be None when the upload form omits it (node sets it
# directly on the Firestore call doc). Fall back to the call doc so that
# dispatch-channel strictness works regardless of how the call arrived.
effective_talkgroup_name = talkgroup_name or call_doc.get("talkgroup_name")
is_dispatch = _is_dispatch_channel(effective_talkgroup_name)
if effective_talkgroup_name != talkgroup_name:
logger.info(
f"Correlator: talkgroup_name missing from request for call {call_id}, "
f"resolved from call doc: {effective_talkgroup_name!r} → is_dispatch={is_dispatch}"
)
tg_matches = [
inc for inc in all_active
@@ -285,7 +294,7 @@ async def correlate_call(
candidate = tg_recent[0]
logger.info(
f"Correlator fast/single: call {call_id} vs incident {candidate['incident_id']} "
f"tg_name={talkgroup_name!r} is_dispatch={is_dispatch} "
f"tg_name={effective_talkgroup_name!r} is_dispatch={is_dispatch} "
f"idle={round(_incident_idle_minutes(candidate, now), 1)}min "
f"call_units={call_units} inc_units={candidate.get('units')} "
f"call_coords={'yes' if coords else 'no'} inc_coords={'yes' if candidate.get('location_coords') else 'no'}"
@@ -324,7 +333,7 @@ async def correlate_call(
# dispatch channel should create its own incident, not be force-merged.
logger.info(
f"Correlator fast/disambig: call {call_id} vs incident {candidate['incident_id']} "
f"tg_name={talkgroup_name!r} is_dispatch={is_dispatch} "
f"tg_name={effective_talkgroup_name!r} is_dispatch={is_dispatch} "
f"idle={round(_incident_idle_minutes(candidate, now), 1)}min "
f"call_units={call_units} inc_units={candidate.get('units')} "
f"call_coords={'yes' if coords else 'no'} inc_coords={'yes' if candidate.get('location_coords') else 'no'}"