From 7bd64c7f4abff020c67798c3bc039d6552f2f217 Mon Sep 17 00:00:00 2001 From: Shanith K K Date: Thu, 9 Nov 2023 19:39:26 +0530 Subject: [PATCH] chore: update userdata status field with boolean --- actions/workflow-invoker/src/lib.rs | 4 ++-- actions/workflow-invoker/src/types/data.rs | 11 +---------- actions/workflow-management/src/lib.rs | 9 +++++---- actions/workflow-management/src/types/topic.rs | 2 +- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/actions/workflow-invoker/src/lib.rs b/actions/workflow-invoker/src/lib.rs index 46b901a3..c3440435 100644 --- a/actions/workflow-invoker/src/lib.rs +++ b/actions/workflow-invoker/src/lib.rs @@ -73,7 +73,7 @@ impl Action { let trigger = self.params.polkadot_payout_trigger.clone(); - if user.status == "active".to_string() { + if user.status { if self .get_context() .invoke_trigger(&trigger, &serde_json::json!({"data": user.input_data})) @@ -139,7 +139,7 @@ mod tests { let doc = serde_json::json!({ "data": [{ "user_id" : "asdf", - "status" : "active", + "status" : true, "input_data" :{ "url": "todo!()".to_string(), "validator": "todo!()".to_string(), "owner_key": "todo!()".to_string() } }] }); diff --git a/actions/workflow-invoker/src/types/data.rs b/actions/workflow-invoker/src/types/data.rs index e8a00d69..300bba0a 100644 --- a/actions/workflow-invoker/src/types/data.rs +++ b/actions/workflow-invoker/src/types/data.rs @@ -1,13 +1,4 @@ use serde_derive::{Deserialize, Serialize}; - -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct DbDatas { - pub endpoint: String, - pub validator: String, - pub key: String, -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Topic { #[serde(rename = "_id")] @@ -21,6 +12,6 @@ pub struct Topic { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)] pub struct UserData { pub user_id: String, - pub status: String, + pub status: bool, pub input_data: serde_json::Value, } diff --git a/actions/workflow-management/src/lib.rs b/actions/workflow-management/src/lib.rs index 5ae826ff..dfea79d6 100644 --- a/actions/workflow-management/src/lib.rs +++ b/actions/workflow-management/src/lib.rs @@ -126,7 +126,7 @@ impl Action { &serde_json::json!({ "data": [{ "user_id": user_id, - "status": String::from("active"), + "status": true, "input_data": db_input }] }), @@ -145,7 +145,7 @@ impl Action { None => { let new_user = UserData { user_id, - status: "active".to_string(), + status: true, input_data: db_input, }; doc.data.push(new_user); @@ -169,8 +169,9 @@ impl Action { user_index = Some(index); } } + let status = self.params.status.clone() == "active".to_string(); match user_index { - Some(x) => doc.data[x].status = self.params.status.clone(), + Some(x) => doc.data[x].status = status, None => (), } @@ -655,7 +656,7 @@ mod tests { let res_data = workflow_management_db_context.get_document("418a8b8c-02b8-11ec-9a03-0242ac130003"); let res = serde_json::from_value::(res_data.unwrap()); - println!("{:?}", res); + assert!(res.is_ok()); couchdb.delete().await.expect("Stopping Container Failed"); } diff --git a/actions/workflow-management/src/types/topic.rs b/actions/workflow-management/src/types/topic.rs index fd52c1fc..24a9db85 100644 --- a/actions/workflow-management/src/types/topic.rs +++ b/actions/workflow-management/src/types/topic.rs @@ -13,6 +13,6 @@ pub struct Topic { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)] pub struct UserData { pub user_id: String, - pub status: String, + pub status: bool, pub input_data: serde_json::Value, }