From 8c795a2a498968fbe4478583dc080abc47061131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Thu, 12 Dec 2024 17:10:41 -0300 Subject: [PATCH 1/2] Add new fields to user struct Those fields are useful for user rate --- src/user.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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, } } } From 42be791235a1807a3689dd982eb801c30f55db62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Thu, 12 Dec 2024 17:11:52 -0300 Subject: [PATCH 2/2] bumps to 0.6.16 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 "]