diff --git a/rs/packages/db/src/lib.rs b/rs/packages/db/src/lib.rs index e1f758d2..3da1dd9e 100644 --- a/rs/packages/db/src/lib.rs +++ b/rs/packages/db/src/lib.rs @@ -128,10 +128,10 @@ pub trait Model: Sized + Unpin + Send + Sync + Serialize + DeserializeOwned { Self::cl_as() } - async fn distinct_string( + async fn distinct_string>( key: &str, filter: impl Into> + Send, - ) -> MongoResult> { + ) -> MongoResult { let items = Self::cl().distinct(key, filter, None).await?; let set = items .into_iter() @@ -144,11 +144,11 @@ pub trait Model: Sized + Unpin + Send + Sync + Serialize + DeserializeOwned { Ok(set) } - async fn distinct_string_with_session( + async fn distinct_string_with_session>( key: &str, filter: impl Into> + Send, session: &mut ClientSession, - ) -> MongoResult> { + ) -> MongoResult { let items = Self::cl() .distinct_with_session(key, filter, None, session) .await?; diff --git a/rs/packages/db/src/models/deployment/mod.rs b/rs/packages/db/src/models/deployment/mod.rs index 5b03638b..99d860e2 100644 --- a/rs/packages/db/src/models/deployment/mod.rs +++ b/rs/packages/db/src/models/deployment/mod.rs @@ -106,10 +106,7 @@ pub async fn check_now() -> Result<(), mongodb::error::Error> { }; let active_deployment_ids: Vec = - Deployment::distinct_string(crate::KEY_ID, active_filter) - .await? - .into_iter() - .collect(); + Deployment::distinct_string(crate::KEY_ID, active_filter).await?; let mut to_close_deployment_ids = HashSet::::new(); @@ -120,7 +117,7 @@ pub async fn check_now() -> Result<(), mongodb::error::Error> { StreamConnection::KEY_DEPLOYMENT_ID: { "$nin": &active_deployment_ids }, }; - let ids = + let ids: Vec = StreamConnection::distinct_string(StreamConnection::KEY_DEPLOYMENT_ID, filter).await?; to_close_deployment_ids.extend(ids); @@ -133,7 +130,7 @@ pub async fn check_now() -> Result<(), mongodb::error::Error> { StreamConnectionLite::KEY_DEPLOYMENT_ID: { "$nin": &active_deployment_ids }, }; - let ids = + let ids: Vec = StreamConnectionLite::distinct_string(StreamConnection::KEY_DEPLOYMENT_ID, filter).await?; to_close_deployment_ids.extend(ids); @@ -146,8 +143,9 @@ pub async fn check_now() -> Result<(), mongodb::error::Error> { WsStatsConnection::KEY_CURRENT_DEPLOYMENT_ID: { "$nin": &active_deployment_ids }, }; - let ids = - StreamConnectionLite::distinct_string(StreamConnection::KEY_DEPLOYMENT_ID, filter).await?; + let ids: Vec = + WsStatsConnection::distinct_string(WsStatsConnection::KEY_CURRENT_DEPLOYMENT_ID, filter) + .await?; to_close_deployment_ids.extend(ids); } @@ -157,9 +155,7 @@ pub async fn check_now() -> Result<(), mongodb::error::Error> { } let deployment_ids: Vec = to_close_deployment_ids.into_iter().collect(); - let deployment_filter = doc! { - Deployment::KEY_ID: { "$in": deployment_ids }, - }; + let deployment_filter = doc! { Deployment::KEY_ID: { "$in": deployment_ids } }; let mut r = Deployment::cl().find(deployment_filter, None).await?;