Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into k8s-deploy
Browse files Browse the repository at this point in the history
tsunyoku authored Nov 16, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 37cf619 + f4d5b4e commit d232d49
Showing 3 changed files with 86 additions and 49 deletions.
107 changes: 85 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ bcrypt = "0.13.0"
uuid = { version = "1.2.1", features = ["v4"] }
futures = "0.3.17"
strsim = "0.10.0"
akatsuki-pp-rs = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "764da0dbf42ed80441acf99d070aaedabaed4b75", features = [
akatsuki-pp-rs = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "96421f54f435bd5c6aa2d90730512e5672b14609", features = [
"async_tokio",
] }
reqwest = "0.11"
@@ -50,9 +50,6 @@ skill-rebalance = { package = "akatsuki-pp", git = "https://github.com/osuAkatsu
] }
rust-s3 = "0.33.0"
structured-logger = "1.0.3"
the = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "4ae182f4f294e6ac34eca1dc2e5f676748c4fd76", features = [
"async_tokio",
] }

[profile.release]
lto = "fat"
23 changes: 0 additions & 23 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ use skill_rebalance::{
Beatmap as SkillRebalanceBeatmap, BeatmapExt as SkillRebalanceBeatmapExt,
GameMode as SkillRebalanceGameMode,
};
use the::Beatmap as TheBeatmap;

fn round(x: f32, decimals: u32) -> f32 {
let y = 10i32.pow(decimals) as f32;
@@ -96,26 +95,6 @@ async fn calculate_skill_rebalance_pp(
Ok(pp)
}

async fn calculate_the_pp(score: &RippleScore, context: Arc<Context>) -> anyhow::Result<f32> {
let beatmap_bytes =
usecases::beatmaps::fetch_beatmap_osu_file(score.beatmap_id, context).await?;
let beatmap = TheBeatmap::from_bytes(&beatmap_bytes).await?;

let result = the::osu_2019::OsuPP::new(&beatmap)
.mods(score.mods as u32)
.combo(score.max_combo as usize)
.misses(score.count_misses as usize)
.accuracy(score.accuracy)
.calculate();

let mut pp = round(result.pp as f32, 2);
if pp.is_infinite() || pp.is_nan() {
pp = 0.0;
}

Ok(pp)
}

async fn process_scores(
rework: &Rework,
scores: Vec<RippleScore>,
@@ -126,10 +105,8 @@ async fn process_scores(
for score in &scores {
let new_pp = match rework.rework_id {
10 => calculate_conceptual_pp(score, context.clone()).await?,
11 => calculate_conceptual_pp(score, context.clone()).await?,
12 => calculate_conceptual_pp(score, context.clone()).await?,
13 => calculate_skill_rebalance_pp(score, context.clone()).await?,
14 => calculate_the_pp(score, context.clone()).await?,
_ => unreachable!(),
};

0 comments on commit d232d49

Please sign in to comment.