Skip to content

Commit

Permalink
Merge pull request #88 from osu-tournament-rating/hotfix/decay-timest…
Browse files Browse the repository at this point in the history
…amps

rewrite decay
  • Loading branch information
hburn7 authored Jan 6, 2025
2 parents 607c720 + 974c6f4 commit 77d5bf9
Show file tree
Hide file tree
Showing 9 changed files with 380 additions and 1,615 deletions.
1,236 changes: 9 additions & 1,227 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,23 @@ path = "src/main.rs"
[dependencies]
dotenv = "0.15.0"
indicatif = "0.17.7"
reqwest = { version = "0.11.24", features = ["json"] }
serde = { version = "1.0.196", features = ["derive"] }
tokio = { version = "1.36.0", features = ["full"] }
chrono = { version = "0.4.33", features = ["serde"] }
openskill = "0.0.1"
statrs = "0.16.0"
serde_repr = "0.1.18"
lazy_static = "1.4.0"
itertools = "0.12.1"
indexmap = "2.2.6"
approx = "0.5.1"
log = "0.4.22"
strum = "0.26.3"
strum_macros = "0.26.4"
rand = "0.8.5"
criterion = "0.5.1"
tokio-postgres = { version = "0.7.11", features = ["with-chrono-0_4"] }
serde_json = "1.0.114"
postgres-types = "0.2.7"

[dev-dependencies]
async-once-cell = "0.5.3"
criterion = { version = "0.5.1", features = ["html_reports"] }
httpmock = "0.7.0"
rand = { version = "0.8.5", features = ["small_rng"] }
serde_json = "1.0.114"

[lints.rust]
dead_code = "allow"
Expand Down
7 changes: 7 additions & 0 deletions src/database/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl DbClient {
//
// We can safely assume that for all matches awaiting processor data every
// game and game score is completely done with processing
println!("Fetching matches...");
let rows = self.client.query("
SELECT
t.id AS tournament_id, t.name AS tournament_name, t.ruleset AS tournament_ruleset,
Expand All @@ -66,6 +67,8 @@ impl DbClient {
AND gs.verification_status = 4
ORDER BY gs.id", &[]).await.unwrap();

println!("Matches fetched, iterating...");

for row in rows {
let match_id = row.get::<_, i32>("match_id");
let game_id = row.get::<_, i32>("game_id");
Expand All @@ -83,6 +86,7 @@ impl DbClient {
game_scores_link_map.entry(game_id).or_default().push(score_id);
}

println!("Linking ids...");
for (game_id, mut score_ids) in game_scores_link_map {
score_ids.dedup();

Expand Down Expand Up @@ -110,6 +114,7 @@ impl DbClient {
let mut matches = matches_map.values().cloned().collect_vec();
matches.sort_by(|a, b| a.start_time.cmp(&b.start_time));

println!("Match fetching complete");
matches
}

Expand Down Expand Up @@ -186,6 +191,7 @@ impl DbClient {
}

pub async fn get_players(&self) -> Vec<Player> {
println!("Fetching players...");
let mut players: Vec<Player> = Vec::new();
let rows = self
.client
Expand Down Expand Up @@ -226,6 +232,7 @@ impl DbClient {
}
}

println!("Players fetched");
players
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use otr_processor::{
database::db::DbClient,
model::{otr_model::OtrModel, rating_utils::initial_ratings},
model::{otr_model::OtrModel, rating_utils::create_initial_ratings},
utils::test_utils::generate_country_mapping_players
};
use std::{collections::HashMap, env};
Expand All @@ -17,7 +17,7 @@ async fn main() {
let players = client.get_players().await;

// 3. Generate initial ratings
let initial_ratings = initial_ratings(&players);
let initial_ratings = create_initial_ratings(&players, &matches);

// 4. Generate country mapping and set
let country_mapping: HashMap<i32, String> = generate_country_mapping_players(&players);
Expand Down
2 changes: 1 addition & 1 deletion src/model/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub const DEFAULT_RATING: f64 = 15.0 * MULTIPLIER;
pub const TAU: f64 = DEFAULT_VOLATILITY / 100.0;
pub const BETA: f64 = DEFAULT_VOLATILITY / 2.0;
pub const KAPPA: f64 = 0.0001;
pub const DECAY_DAYS: u64 = 115;
pub const DECAY_DAYS: u64 = 121;
pub const DECAY_MINIMUM: f64 = 15.0 * MULTIPLIER;
pub const DECAY_RATE: f64 = 0.06 * MULTIPLIER;
pub const ABSOLUTE_RATING_FLOOR: f64 = 100.0;
Expand Down
Loading

0 comments on commit 77d5bf9

Please sign in to comment.