diff --git a/vtse-server/src/state.rs b/vtse-server/src/state.rs index 01c877f..ec43d26 100644 --- a/vtse-server/src/state.rs +++ b/vtse-server/src/state.rs @@ -4,15 +4,9 @@ use sodiumoxide::crypto::pwhash::argon2id13::{pwhash_verify, HashedPassword}; use sqlx::{query, PgPool}; use std::convert::TryFrom; use thiserror::Error; -use vtse_common::{ - net::{ServerResponse, UserError}, - user::User, -}; -use vtse_common::{stock::Stock, user::UserBalance}; -use vtse_common::{ - stock::StockSymbol, - user::{ApiKey, Password, UserDebt, Username}, -}; +use vtse_common::net::{ServerResponse, UserError}; +use vtse_common::stock::{Stock, StockSymbol}; +use vtse_common::user::{ApiKey, Password, User, UserBalance, UserDebt, Username}; #[derive(Error, Debug)] pub(crate) enum StateError { @@ -234,6 +228,9 @@ impl AppState { todo!() } + // todo: fetch_one needs to turn into fetch_optional, else we can't discriminate user versus + // server error. + async fn get_user_balance(user_id: i32, pool: &PgPool) -> Result { query!("SELECT balance FROM users where user_id = $1", user_id) .fetch_one(pool)