From ec1d50f655c05d9dec0c4b01fd1039e9c5525f34 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 9 Jul 2022 20:01:05 +0200 Subject: refactor: pass on both Bot and BotVersion to MatchPlayer --- planetwars-server/src/modules/ranking.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'planetwars-server/src/modules/ranking.rs') diff --git a/planetwars-server/src/modules/ranking.rs b/planetwars-server/src/modules/ranking.rs index 751c35e..3182ce2 100644 --- a/planetwars-server/src/modules/ranking.rs +++ b/planetwars-server/src/modules/ranking.rs @@ -37,18 +37,14 @@ pub async fn run_ranker(db_pool: DbPool) { async fn play_ranking_match(selected_bots: Vec, db_pool: DbPool) { let db_conn = db_pool.get().await.expect("could not get db pool"); - let mut code_bundles = Vec::new(); + let mut players = Vec::new(); for bot in &selected_bots { - let code_bundle = db::bots::active_bot_version(bot.id, &db_conn) - .expect("could not get active code bundle"); - code_bundles.push(code_bundle); + let version = db::bots::active_bot_version(bot.id, &db_conn) + .expect("could not get active bot version"); + let player = MatchPlayer::from_bot_version(bot, &version); + players.push(player); } - let players = code_bundles - .iter() - .map(MatchPlayer::from_code_bundle) - .collect::>(); - let mut run_match = RunMatch::from_players(players); run_match .store_in_database(&db_conn) -- cgit v1.2.3