diff --git a/bank_core/src/account.rs b/bank_core/src/account.rs index de24c58..0b2a49e 100644 --- a/bank_core/src/account.rs +++ b/bank_core/src/account.rs @@ -12,16 +12,8 @@ pub struct Account { pub id: Uuid, pub user: Uuid, pub name: String, - pub balance: u64, } -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] -#[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))] -pub struct AccountInfo { - pub id: Uuid, - pub user: Uuid, - pub name: String, -} #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] #[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))] pub struct UserAccountInfo { @@ -40,8 +32,8 @@ pub struct ReducedAccountInfo { impl PaginationType for UserAccountInfo { const NAME: &str = "UserAccounts"; } -impl PaginationType for AccountInfo { +impl PaginationType for Account { const NAME: &str = "Accounts"; } -make_schemas!((); (Account, AccountInfo, UserAccountInfo, Pagination, Pagination)); +make_schemas!((); (Account, UserAccountInfo, Pagination, Pagination)); diff --git a/bank_core/src/lib.rs b/bank_core/src/lib.rs index da5b004..16e84c2 100644 --- a/bank_core/src/lib.rs +++ b/bank_core/src/lib.rs @@ -9,7 +9,6 @@ pub use schemas::*; mod error; mod util; pub use error::*; -use serde::{Deserialize, Serialize}; pub use util::*; make_schemas!((Credentials); (ApiError, TokenResponse), [account::schemas, chat::schemas, transaction::schemas, user::schemas, meta::schemas]); diff --git a/migrations/000001_chats.sql b/migrations/000001_chats.sql index 9588f27..826d472 100644 --- a/migrations/000001_chats.sql +++ b/migrations/000001_chats.sql @@ -13,6 +13,7 @@ create table chat_messages( ); create index chat_messages_chat_index on chat_messages(chat); +create index chat_messages_chat_and_id_index on chat_messages(chat, id); create table chat_members( chat uuid not null, diff --git a/src/api/account.rs b/src/api/account.rs index 4db59d1..000de25 100644 --- a/src/api/account.rs +++ b/src/api/account.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use axum::{Router, extract::Path, routing::get}; use bank_core::{ ApiError, - account::AccountInfo, + account::Account, pagination::Pagination, transaction::{FullTransaction, TransactionQuery}, }; @@ -52,7 +52,7 @@ pub async fn list_accounts( EState(state): State, _: Auth, PaginationQuery(pagination): PaginationQuery, -) -> Result>, Error> { +) -> Result>, Error> { let conn = state.conn().await?; let result = Accounts::list_all(&conn, pagination).await?; Ok(Json(result)) diff --git a/src/model/account.rs b/src/model/account.rs index 2696261..ebef25b 100644 --- a/src/model/account.rs +++ b/src/model/account.rs @@ -1,5 +1,5 @@ use bank_core::{ - account::{AccountInfo, UserAccountInfo}, + account::{Account, UserAccountInfo}, pagination::{Pagination, RequestPagination}, }; use deadpool_postgres::GenericClient; @@ -11,8 +11,8 @@ use crate::api::TransactionBuilder; use super::count; -fn account_info_from_row(row: Row) -> AccountInfo { - AccountInfo { +fn account_info_from_row(row: Row) -> Account { + Account { id: row.get("id"), user: row.get("user"), name: row.get("name"), @@ -55,7 +55,7 @@ impl Accounts { pub async fn list_all( client: &impl GenericClient, pagination: RequestPagination, - ) -> Result, tokio_postgres::Error> { + ) -> Result, tokio_postgres::Error> { let stmt = client .prepare_cached("select id,\"user\",name from accounts limit $1 offset $2") .await?;