Skip to content

Commit

Permalink
log: add some tracing logs to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasauler committed Dec 17, 2024
1 parent c4f400d commit 3a46547
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/client/pluggy/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub async fn list_accounts(api_key: &str, item_id: &Uuid) -> anyhow::Result<List
.await?;

if !(matches!(resp.status(), StatusCode::OK)) {
tracing::error!("received non OK status code");
bail!("unexpected status code returned from list accounts")
}

Expand Down
6 changes: 5 additions & 1 deletion src/client/pluggy/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ pub async fn list_transactions(
StatusCode::OK => resp.json().await?,
StatusCode::BAD_REQUEST => return Ok(ListTransactionsOutcome::Missing),
StatusCode::INTERNAL_SERVER_ERROR => return Ok(ListTransactionsOutcome::Internal),
_ => bail!("unknown error: {}", resp.text().await?),
_ => {
let res = resp.text().await?;
tracing::error!(?res, "received unexpected error from list transactions");
bail!("unknown error: {}", res)
}
};

Ok(ListTransactionsOutcome::Success(transactions))
Expand Down
9 changes: 7 additions & 2 deletions src/features/expenses.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Context;
use plotly::{Layout, Plot, Scatter};
use sqlx::PgPool;
use std::{cmp::Reverse, collections::BTreeMap};
Expand Down Expand Up @@ -37,12 +38,14 @@ pub async fn process_pluggy_expenses(
let Some(item_id) =
crate::queries::pluggy_items::find_latest_for_user(&db_pool, user_id).await?
else {
tracing::error!("aaaaaaa should create pluggy item");
todo!("create pluggy item")
};

let accounts =
crate::client::pluggy::account::list_accounts(pluggy_api_key, &item_id.external_item_id)
.await?
.await
.context("failed to list accounts from pluggy api")?
.results;

for account in accounts {
Expand All @@ -59,8 +62,10 @@ pub async fn process_pluggy_expenses(
.map(|t| t.date - time::Duration::days(1))
.as_ref(),
)
.await?
.await
.context("failed to list accounts from pluggy api")?
else {
tracing::error!("don't know yet");
panic!("don't know yet")
};

Expand Down

0 comments on commit 3a46547

Please sign in to comment.