Slight polishing.

This commit is contained in:
2026-10-12 14:04:59 +02:00
parent 945ae46dbe
commit 29fcf284be
5 changed files with 37 additions and 13 deletions
+14 -6
View File
@@ -65,10 +65,14 @@ async fn get_transaction(
let transaction = repository::transactions::get_by_id(&pool, user_id, id)
.await?
.ok_or(AppError::NotFound)?;
let accounts =
get_accounts_for_transactions(&pool, user_id, std::slice::from_ref(&transaction)).await?;
let account = repository::accounts::get_by_id(&pool, user_id, transaction.account_id)
.await?
.ok_or(AppError::RaceCondition)?; // Account should exist!
Ok(Json(create_response(transaction, &accounts)?))
Ok(Json(create_response(
transaction,
&HashMap::from([(account.id, account)]),
)?))
}
#[axum::debug_handler]
@@ -95,9 +99,13 @@ async fn upsert_transaction(
StatusCode::CREATED
};
let accounts = HashMap::from([(account.id, account)]);
Ok((status, Json(create_response(upserted.current, &accounts)?)))
Ok((
status,
Json(create_response(
upserted.current,
&HashMap::from([(account.id, account)]),
)?),
))
}
#[axum::debug_handler]