aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/modules/ranking.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-07-09 20:01:05 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-07-09 20:01:05 +0200
commitec1d50f655c05d9dec0c4b01fd1039e9c5525f34 (patch)
tree90973a749e5d67ddf9749b23f82a41beba0ac812 /planetwars-server/src/modules/ranking.rs
parent7eb02a2efc8f0bb8ec411c5af0f648aeda939226 (diff)
downloadplanetwars.dev-ec1d50f655c05d9dec0c4b01fd1039e9c5525f34.tar.xz
planetwars.dev-ec1d50f655c05d9dec0c4b01fd1039e9c5525f34.zip
refactor: pass on both Bot and BotVersion to MatchPlayer
Diffstat (limited to 'planetwars-server/src/modules/ranking.rs')
-rw-r--r--planetwars-server/src/modules/ranking.rs14
1 files changed, 5 insertions, 9 deletions
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<Bot>, 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::<Vec<_>>();
-
let mut run_match = RunMatch::from_players(players);
run_match
.store_in_database(&db_conn)