diff --git a/Cargo.lock b/Cargo.lock index 4a9faa2..16ce515 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1991,8 +1991,9 @@ dependencies = [ [[package]] name = "mostro-core" -version = "0.6.18" -source = "git+https://github.com/MostroP2P/mostro-core.git?branch=user-table-pubkey#404e7632f644bc57b171b584cd0a2dfbca68dfd4" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598112169173ad9c97abab86cb9b1aed551e78201bb938df5cd845f35edc0c08" dependencies = [ "anyhow", "bitcoin", diff --git a/Cargo.toml b/Cargo.toml index 6f5bcbe..2e81989 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,7 @@ uuid = { version = "1.8.0", features = [ "serde", ] } reqwest = { version = "0.12.1", features = ["json"] } -# mostro-core = { version = "0.6.18", features = ["sqlx"] } -mostro-core = { git = "https://github.com/MostroP2P/mostro-core.git", branch = "user-table-pubkey", features = ["sqlx"] } +mostro-core = { version = "0.6.19", features = ["sqlx"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } config = "0.14.0" @@ -47,4 +46,4 @@ clap = { version = "4.5.19", features = ["derive"] } lnurl-rs = "0.9.0" openssl = { version = "0.10.66", features = ["vendored"] } once_cell = "1.20.2" -bitcoin = "0.32.5" \ No newline at end of file +bitcoin = "0.32.5" diff --git a/src/app/rate_user.rs b/src/app/rate_user.rs index 3a4a441..57c5f6d 100644 --- a/src/app/rate_user.rs +++ b/src/app/rate_user.rs @@ -143,13 +143,12 @@ pub async fn update_user_reputation_action( // Going on with calculation // increment first user_to_vote.total_reviews += 1; + let old_rating = user_to_vote.total_rating as f64; + // recompute new rating + user_to_vote.total_rating = old_rating + + ((user_to_vote.last_rating as f64) - old_rating) / (user_to_vote.total_reviews as f64); // Store last rating user_to_vote.last_rating = rating.into(); - // recompute rating - user_to_vote.total_rating = - ((user_to_vote.total_rating * (user_to_vote.total_reviews - 1) as f64) + rating as f64) - / user_to_vote.total_reviews as f64; - // Create new rating event let reputation_event = Rating::new( user_to_vote.total_reviews as u64,