Skip to content

Commit

Permalink
Merge branch 'main' into k8s-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku authored Nov 5, 2023
2 parents c13f80e + d410144 commit 048ea0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ AWS_SECRET_ACCESS_KEY=
AWS_ENDPOINT_URL=
AWS_BUCKET_NAME=
SERVICE_READINESS_TIMEOUT=60
RUST_LOG=performance_service=info
RUST_LOG=performance_service=info
12 changes: 9 additions & 3 deletions src/api/routes/calculate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ async fn calculate_relax_pp(

let mut pp = round(result.pp as f32, 2);
if pp.is_infinite() || pp.is_nan() {
log::warn!("Calculated pp is infinite or NaN, setting to 0");
pp = 0.0;
}

let mut stars = round(result.difficulty.stars as f32, 2);
if stars.is_infinite() || stars.is_nan() {
log::warn!("Calculated star rating is infinite or NaN, setting to 0");
stars = 0.0;
}

Expand Down Expand Up @@ -91,11 +93,13 @@ async fn calculate_rosu_pp(

let mut pp = round(result.pp() as f32, 2);
if pp.is_infinite() || pp.is_nan() {
log::warn!("Calculated pp is infinite or NaN, setting to 0");
pp = 0.0;
}

let mut stars = round(result.stars() as f32, 2);
if stars.is_infinite() || stars.is_nan() {
log::warn!("Calculated star rating is infinite or NaN, setting to 0");
stars = 0.0;
}

Expand Down Expand Up @@ -142,9 +146,6 @@ async fn calculate_play(
for request in requests {
let raw_result = if request.mods & RX > 0 && request.mode == 0 {
calculate_relax_pp(&request, ctx.clone()).await
} else {
calculate_rosu_pp(&request, ctx.clone()).await
};

let result = match raw_result {
Ok(result) => result,
Expand All @@ -157,6 +158,11 @@ async fn calculate_play(
},
};

log::info!(
"Calculated performance: {}pp for beatmap {}",
result.pp,
request.beatmap_id
);
results.push(result);
}

Expand Down

0 comments on commit 048ea0c

Please sign in to comment.