Skip to content

Commit

Permalink
fix: add current deployment id and start deploment id to ws stats con… (
Browse files Browse the repository at this point in the history
#292)

…nections
  • Loading branch information
ramiroaisen authored Mar 11, 2024
2 parents fe3dce0 + 0a0115a commit 715b252
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions defs/db/WsStatsConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion rs/packages/api/src/ws_stats/routes/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion rs/packages/db/src/models/deployment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
5 changes: 4 additions & 1 deletion rs/packages/db/src/models/ws_stats_connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ pub struct WsStatsConnection {
#[serde(rename = "st")]
pub station_id: String,

#[serde(rename = "sd")]
pub start_deployment_id: Option<String>,

#[serde(rename = "dp")]
pub deployment_id: String,
pub current_deployment_id: String,

// #[serde(with = "serde_util::as_f64::option")]
// pub transfer_bytes: Option<u64>,
Expand Down

0 comments on commit 715b252

Please sign in to comment.