diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-10-13 23:42:44 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-10-13 23:42:44 +0200 |
commit | 353ecd4c165042234e9f976b158bc970517940f5 (patch) | |
tree | c057b7f8bcad2fe300da9391aff539409a0f83b0 /planetwars-server/src | |
parent | eb2cbb15fbea6dd6f800598329cd5cc892090d7b (diff) | |
download | planetwars.dev-353ecd4c165042234e9f976b158bc970517940f5.tar.xz planetwars.dev-353ecd4c165042234e9f976b158bc970517940f5.zip |
basic test for list_matches and had_errors
Diffstat (limited to 'planetwars-server/src')
-rw-r--r-- | planetwars-server/src/modules/ranking.rs | 4 | ||||
-rw-r--r-- | planetwars-server/src/routes/matches.rs | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/planetwars-server/src/modules/ranking.rs b/planetwars-server/src/modules/ranking.rs index 92f0f8a..aa4060c 100644 --- a/planetwars-server/src/modules/ranking.rs +++ b/planetwars-server/src/modules/ranking.rs @@ -44,12 +44,12 @@ pub async fn run_ranker(config: Arc<GlobalConfig>, db_pool: DbPool) { Some(map) => map, }; - play_ranking_match(config.clone(), map, selected_bots, db_pool.clone()).await; + play_ranked_match(config.clone(), map, selected_bots, db_pool.clone()).await; recalculate_ratings(&mut db_conn).expect("could not recalculate ratings"); } } -async fn play_ranking_match( +pub async fn play_ranked_match( config: Arc<GlobalConfig>, map: Map, selected_bots: Vec<(Bot, BotVersion)>, diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs index 99c6d1a..6845e90 100644 --- a/planetwars-server/src/routes/matches.rs +++ b/planetwars-server/src/routes/matches.rs @@ -32,6 +32,7 @@ pub struct ApiMatchPlayer { bot_version_id: Option<i32>, bot_id: Option<i32>, bot_name: Option<String>, + had_errors: Option<bool>, } #[derive(Serialize, Deserialize)] @@ -117,10 +118,11 @@ pub fn match_data_to_api(data: matches::FullMatchData) -> ApiMatch { players: data .match_players .iter() - .map(|_p| ApiMatchPlayer { - bot_version_id: _p.bot_version.as_ref().map(|cb| cb.id), - bot_id: _p.bot.as_ref().map(|b| b.id), - bot_name: _p.bot.as_ref().map(|b| b.name.clone()), + .map(|p| ApiMatchPlayer { + bot_version_id: p.bot_version.as_ref().map(|cb| cb.id), + bot_id: p.bot.as_ref().map(|b| b.id), + bot_name: p.bot.as_ref().map(|b| b.name.clone()), + had_errors: p.base.had_errors, }) .collect(), winner: data.base.winner, |