Skip to content

Commit

Permalink
use datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Dec 4, 2024
1 parent 6f1daf2 commit 5f3f2e4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/analytics/enrich_account_funding.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use chrono::{DateTime, Utc};
use log::trace;
use neo4rs::{Graph, Query};
use serde::{Deserialize, Serialize};
use std::{
Expand Down Expand Up @@ -131,14 +132,15 @@ impl BalanceTracker {
r#"
UNWIND {map} AS account
MERGE (sa:SwapAccount {{swap_id: account.swap_id}})
MERGE (ul:UserLedger {{date: account.date}})
MERGE (ul:UserLedger {{date: datetime(account.date)}})
SET ul.balance = account.balance,
ul.funding = account.funding,
ul.inflows = account.inflows,
ul.outflows = account.outflows,
ul.user_flows = account.user_flows,
ul.accepter_flows = account.accepter_flows
MERGE (sa)-[r:Daily {{date: account.date}}]->(ul)
MERGE (sa)-[r:Daily]->(ul)
SET r.date = datetime(account.date)
RETURN COUNT(r) as merged_relations
"#,
)
Expand Down Expand Up @@ -187,8 +189,8 @@ pub async fn submit_ledger(balances: &BalanceTracker, pool: &Graph) -> Result<u6
let mut result = pool.execute(query).await?;

while let Some(r) = result.next().await? {
dbg!(&r);
if let Ok(i) = r.get::<u64>("merged_relations") {
trace!("merged ledger in tx: {i}");
merged_relations += i;
};
}
Expand Down

0 comments on commit 5f3f2e4

Please sign in to comment.