Skip to content

Commit fdb5aa6

Browse files
authored
Merge pull request #71 from MostroP2P/rate-new-fields
Rate new fields
2 parents 72fe31f + 42be791 commit fdb5aa6

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mostro-core"
3-
version = "0.6.15"
3+
version = "0.6.16"
44
edition = "2021"
55
license = "MIT"
66
authors = ["Francisco Calderón <[email protected]>"]

src/user.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ use serde::{Deserialize, Serialize};
44
use sqlx::FromRow;
55
#[cfg(feature = "sqlx")]
66
use sqlx_crud::SqlxCrud;
7-
use uuid::Uuid;
87

98
/// Database representation of an user
109
#[cfg_attr(feature = "sqlx", derive(FromRow, SqlxCrud), external_id)]
1110
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
1211
pub struct User {
13-
pub id: Uuid,
12+
pub id: uuid::Uuid,
1413
pub pubkey: String,
1514
pub is_admin: i64,
1615
pub is_solver: i64,
1716
pub is_banned: i64,
1817
pub category: i64,
18+
/// We have to be sure that when a user creates a new order (or takes an order),
19+
/// the trade_index is greater than the one we have in database
20+
pub last_trade_index: i64,
21+
pub total_reviews: i64,
22+
pub total_rating: i64,
23+
pub last_rating: i64,
24+
pub max_rating: i64,
25+
pub min_rating: i64,
1926
pub created_at: i64,
20-
pub trade_index: i64,
2127
}
2228

2329
impl User {
@@ -30,14 +36,19 @@ impl User {
3036
trade_index: i64,
3137
) -> Self {
3238
Self {
33-
id: Uuid::new_v4(),
39+
id: uuid::Uuid::new_v4(),
3440
pubkey,
3541
is_admin,
3642
is_solver,
3743
is_banned,
3844
category,
45+
last_trade_index: trade_index,
46+
total_reviews: 0,
47+
total_rating: 0,
48+
last_rating: 0,
49+
max_rating: 0,
50+
min_rating: 0,
3951
created_at: Utc::now().timestamp(),
40-
trade_index,
4152
}
4253
}
4354
}

0 commit comments

Comments
 (0)