Skip to content

Commit

Permalink
patch merge, missing tx.coin
Browse files Browse the repository at this point in the history
  • Loading branch information
Isa Leveret committed Jan 28, 2025
1 parent 646b38e commit 9a43790
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/cypher_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ FOREACH (_ IN CASE WHEN tx.args IS NOT NULL THEN [1] ELSE [] END |
)
// Conditionally increment the lifetime coins sent
FOREACH (_ IN CASE WHEN tx.amount > 0 THEN [1] ELSE [] END |
MERGE (from)-[relTotal:LifeTime]->(to)
FOREACH (_ IN CASE WHEN tx.coins > 0 THEN [1] ELSE [] END |
SET rel.coins = tx.coins
MERGE (from)-[relTotal:Lifetime]->(to)
SET relTotal.coins = COALESCE(relTotal.coins, 0) + tx.coins
)
Expand Down
3 changes: 2 additions & 1 deletion src/load_tx_cypher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ pub async fn impl_batch_tx_insert(
// cypher queries makes it annoying to do a single insert of users and
// txs
let cypher_string = write_batch_user_create(&list_str);
// dbg!(format!("{:#}",cypher_string));

// Execute the query
let cypher_query = query(&cypher_string);
Expand All @@ -120,7 +119,9 @@ pub async fn impl_batch_tx_insert(
.get("unchanged_accounts")
.context("no unchanged_accounts field")?;

dbg!(&list_str);
let cypher_string = write_batch_tx_string(&list_str);
dbg!(&cypher_string);

// Execute the query
let cypher_query = query(&cypher_string);
Expand Down
13 changes: 5 additions & 8 deletions src/schema_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,23 @@ impl WarehouseTxMaster {
tx_args = st;
}
};
let coins_literal = match &self.relation_label.get_coins_human_readable() {
Some(c) => format!(" coins: {:.2},", c),
None => "".to_string(),
let mut coins_literal = "NULL".to_string();
if let Some(c) = &self.relation_label.get_coins_human_readable() {
coins_literal = format!("{:.2}", c);
};
format!(
r#"{{ args: {maybe_args_here},{maybe_coins_here}tx_hash: "{}", block_datetime: datetime("{}"), block_timestamp: {}, relation: "{}", function: "{}", sender: "{}", recipient: "{}", framework_version: "{}"}}"#,
r#"{{ args: {tx_args}, coins: {coins_literal}, tx_hash: "{}", block_datetime: datetime("{}"), block_timestamp: {}, relation: "{}", function: "{}", sender: "{}", recipient: "{}", framework_version: "{}"}}"#,
self.tx_hash.to_hex_literal(),
self.block_datetime.to_rfc3339(),
self.block_timestamp,
self.relation_label.to_cypher_label(),
self.function,
self.sender.to_hex_literal(),
// TODO: should be from relation_label.get_recipient
self.relation_label
.get_recipient()
.unwrap_or(self.sender)
.to_hex_literal(),
self.framework_version,
maybe_args_here = tx_args,
maybe_coins_here = coins_literal
self.framework_version
)
}

Expand Down

0 comments on commit 9a43790

Please sign in to comment.