Skip to content

Commit

Permalink
chore: update userdata status field with boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
shanithkk committed Nov 9, 2023
1 parent 88a3f09 commit 7bd64c7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions actions/workflow-invoker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
Expand Down Expand Up @@ -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() }
}]
});
Expand Down
11 changes: 1 addition & 10 deletions actions/workflow-invoker/src/types/data.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand All @@ -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,
}
9 changes: 5 additions & 4 deletions actions/workflow-management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Action {
&serde_json::json!({
"data": [{
"user_id": user_id,
"status": String::from("active"),
"status": true,
"input_data": db_input
}]
}),
Expand All @@ -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);
Expand All @@ -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 => (),
}

Expand Down Expand Up @@ -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::<Topic>(res_data.unwrap());
println!("{:?}", res);
assert!(res.is_ok());
couchdb.delete().await.expect("Stopping Container Failed");
}

Expand Down
2 changes: 1 addition & 1 deletion actions/workflow-management/src/types/topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit 7bd64c7

Please sign in to comment.