Skip to content

Commit

Permalink
Merge pull request #71 from MostroP2P/rate-new-fields
Browse files Browse the repository at this point in the history
Rate new fields
  • Loading branch information
grunch authored Dec 12, 2024
2 parents 72fe31f + 42be791 commit fdb5aa6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mostro-core"
version = "0.6.15"
version = "0.6.16"
edition = "2021"
license = "MIT"
authors = ["Francisco Calderón <[email protected]>"]
Expand Down
21 changes: 16 additions & 5 deletions src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
}
}

0 comments on commit fdb5aa6

Please sign in to comment.