Skip to content

Commit

Permalink
allow more fine-picked deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku committed Apr 14, 2024
1 parent 060ae91 commit e9ede8a
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions src/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ async fn recalculate_mode_scores(
rx: i32,
ctx: Arc<Context>,
recalc_ctx: Arc<Mutex<RecalculateContext>>,
mods_value: Option<i32>,
) -> anyhow::Result<()> {
let scores_table = match rx {
0 => "scores",
Expand All @@ -216,6 +217,11 @@ async fn recalculate_mode_scores(
_ => unreachable!(),
};

let mods_query_str = match mods_value {
Some(mods) => format!("AND (mods & {}) > 0", mods),
None => "".to_string(),
};

let scores: Vec<RippleScore> = sqlx::query_as(
&format!(
"SELECT s.id, s.beatmap_md5, s.userid, s.score, s.max_combo, s.full_combo, s.mods, s.300_count,
Expand All @@ -228,8 +234,10 @@ async fn recalculate_mode_scores(
WHERE
completed IN (2, 3)
AND play_mode = ?
{}
ORDER BY pp DESC",
scores_table
scores_table,
mods_query_str,
)
)
.bind(mode)
Expand Down Expand Up @@ -575,6 +583,29 @@ pub async fn serve(context: Context) -> anyhow::Result<()> {
print!("\n");
std::io::stdout().flush()?;

print!("Mod value recalc only (y/n): ");
std::io::stdout().flush()?;

let mut mod_recalc_value_only_str = String::new();
std::io::stdin().read_line(&mut mod_recalc_value_only_str)?;
let mod_recalc_value_only = mod_recalc_value_only_str.to_lowercase().trim() == "y";

print!("\n");
std::io::stdout().flush()?;

let mut mods_value: Option<i32> = None;
if mod_recalc_value_only {
print!("Mods value (int): ");
std::io::stdout().flush()?;

let mut mods_value_str = String::new();
std::io::stdin().read_line(&mut mods_value_str)?;
mods_value = Some(mods_value_str.parse::<i32>().expect("failed to parse mods"));

print!("\n");
std::io::stdout().flush()?;
}

let recalculate_context = Arc::new(Mutex::new(RecalculateContext {
beatmaps: HashMap::new(),
}));
Expand All @@ -595,12 +626,19 @@ pub async fn serve(context: Context) -> anyhow::Result<()> {
rx.clone(),
context_arc.clone(),
recalculate_context.clone(),
mods_value,
)
.await?;
}
} else {
recalculate_mode_scores(mode, 0, context_arc.clone(), recalculate_context.clone())
.await?;
recalculate_mode_scores(
mode,
0,
context_arc.clone(),
recalculate_context.clone(),
mods_value,
)
.await?;
}
}
}
Expand Down

0 comments on commit e9ede8a

Please sign in to comment.