diff --git a/crates/app_feeder_distributor/src/event.rs b/crates/app_feeder_distributor/src/event.rs index a712509..6db4fef 100644 --- a/crates/app_feeder_distributor/src/event.rs +++ b/crates/app_feeder_distributor/src/event.rs @@ -105,28 +105,7 @@ async fn handle_control_event( ws_manager: Option<&Arc>, metadata: &MetadataCache, ) { - // UnitStateChanged is high-frequency and intentionally not persisted; - // it still needs tracing for local observability. All other events are - // persisted via record_event, which emits tracing automatically. - if let AppEvent::UnitStateChanged { - unit_id, - from_state, - to_state, - } = &event - { - tracing::info!("Unit {} state: {} -> {}", unit_id, from_state, to_state); - } - - persist_event_if_needed(&event, pool, ws_manager, metadata).await; -} - -async fn persist_event_if_needed( - event: &AppEvent, - pool: &sqlx::PgPool, - ws_manager: Option<&Arc>, - metadata: &MetadataCache, -) { - let record: Option = match event { + let record: Option = match &event { AppEvent::EquipmentStartCommandSent { equipment_id, unit_id, @@ -280,11 +259,18 @@ async fn persist_event_if_needed( payload: serde_json::json!({ "unit_id": unit_id }), }) } - AppEvent::UnitStateChanged { .. } => None, + // High-frequency, intentionally not persisted; tracing only for local observability. + AppEvent::UnitStateChanged { + unit_id, + from_state, + to_state, + } => { + tracing::info!("Unit {} state: {} -> {}", unit_id, from_state, to_state); + None + } }; - let Some(record) = record else { - return; - }; - record_event(pool, ws_manager.map(Arc::as_ref), record).await; + if let Some(record) = record { + record_event(pool, ws_manager.map(Arc::as_ref), record).await; + } }