diff --git a/defs/db/WsStatsConnection.ts b/defs/db/WsStatsConnection.ts index bd7c7a23..18504bda 100644 --- a/defs/db/WsStatsConnection.ts +++ b/defs/db/WsStatsConnection.ts @@ -5,6 +5,7 @@ import type { DateTime } from "../DateTime.js"; export type WsStatsConnection = { _id: string; st: string; + sd: string | null | undefined; dp: string; du: number | null | undefined; op: boolean; diff --git a/rs/packages/api/src/ws_stats/routes/connection.rs b/rs/packages/api/src/ws_stats/routes/connection.rs index 87e1b772..d5ed6cc2 100644 --- a/rs/packages/api/src/ws_stats/routes/connection.rs +++ b/rs/packages/api/src/ws_stats/routes/connection.rs @@ -177,7 +177,8 @@ impl WsConnectionHandler { let connection = WsStatsConnection { id: connection_id.clone(), station_id: station_id.clone(), - deployment_id, + start_deployment_id: Some(deployment_id.clone()), + current_deployment_id: deployment_id, duration_ms: None, is_open: true, country_code, @@ -208,6 +209,7 @@ impl WsConnectionHandler { let update = doc! { "$set": { + WsStatsConnection::KEY_CURRENT_DEPLOYMENT_ID: &deployment_id, WsStatsConnection::KEY_IS_OPEN: true, WsStatsConnection::KEY_CLOSED_AT: null, }, diff --git a/rs/packages/db/src/models/deployment/mod.rs b/rs/packages/db/src/models/deployment/mod.rs index 8f83c4ec..8c82e534 100644 --- a/rs/packages/db/src/models/deployment/mod.rs +++ b/rs/packages/db/src/models/deployment/mod.rs @@ -286,7 +286,7 @@ pub async fn check_now() -> Result<(), mongodb::error::Error> { }]; let filter = doc! { - WsStatsConnection::KEY_DEPLOYMENT_ID: &deployment.id, + WsStatsConnection::KEY_CURRENT_DEPLOYMENT_ID: &deployment.id, WsStatsConnection::KEY_IS_OPEN: true, }; diff --git a/rs/packages/db/src/models/ws_stats_connection/mod.rs b/rs/packages/db/src/models/ws_stats_connection/mod.rs index 7c7657cf..afb75c58 100644 --- a/rs/packages/db/src/models/ws_stats_connection/mod.rs +++ b/rs/packages/db/src/models/ws_stats_connection/mod.rs @@ -25,8 +25,11 @@ pub struct WsStatsConnection { #[serde(rename = "st")] pub station_id: String, + #[serde(rename = "sd")] + pub start_deployment_id: Option, + #[serde(rename = "dp")] - pub deployment_id: String, + pub current_deployment_id: String, // #[serde(with = "serde_util::as_f64::option")] // pub transfer_bytes: Option,