diff --git a/Cargo.toml b/Cargo.toml index d4e5cbd..6cb040c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mostro-core" -version = "0.6.15" +version = "0.6.16" edition = "2021" license = "MIT" authors = ["Francisco Calderón "] diff --git a/src/user.rs b/src/user.rs index 3edd0f8..91184b0 100644 --- a/src/user.rs +++ b/src/user.rs @@ -4,20 +4,26 @@ use serde::{Deserialize, Serialize}; use sqlx::FromRow; #[cfg(feature = "sqlx")] use sqlx_crud::SqlxCrud; -use uuid::Uuid; /// Database representation of an user #[cfg_attr(feature = "sqlx", derive(FromRow, SqlxCrud), external_id)] #[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)] pub struct User { - pub id: Uuid, + pub id: uuid::Uuid, pub pubkey: String, pub is_admin: i64, pub is_solver: i64, pub is_banned: i64, pub category: i64, + /// We have to be sure that when a user creates a new order (or takes an order), + /// the trade_index is greater than the one we have in database + pub last_trade_index: i64, + pub total_reviews: i64, + pub total_rating: i64, + pub last_rating: i64, + pub max_rating: i64, + pub min_rating: i64, pub created_at: i64, - pub trade_index: i64, } impl User { @@ -30,14 +36,19 @@ impl User { trade_index: i64, ) -> Self { Self { - id: Uuid::new_v4(), + id: uuid::Uuid::new_v4(), pubkey, is_admin, is_solver, is_banned, category, + last_trade_index: trade_index, + total_reviews: 0, + total_rating: 0, + last_rating: 0, + max_rating: 0, + min_rating: 0, created_at: Utc::now().timestamp(), - trade_index, } } }