aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/modules/ranking.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-07-13 19:36:07 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-07-13 19:36:07 +0200
commit668409e76d8cc7797fe627b2e2c3d0223b3db684 (patch)
tree459aae72431fff6d2855422156c3c5640c929690 /planetwars-server/src/modules/ranking.rs
parente69bd14f1d64b0d8b2438a40a069d3647c1edd73 (diff)
downloadplanetwars.dev-668409e76d8cc7797fe627b2e2c3d0223b3db684.tar.xz
planetwars.dev-668409e76d8cc7797fe627b2e2c3d0223b3db684.zip
refactor: unify match save and spawn
Diffstat (limited to 'planetwars-server/src/modules/ranking.rs')
-rw-r--r--planetwars-server/src/modules/ranking.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/planetwars-server/src/modules/ranking.rs b/planetwars-server/src/modules/ranking.rs
index 7147b98..1c35394 100644
--- a/planetwars-server/src/modules/ranking.rs
+++ b/planetwars-server/src/modules/ranking.rs
@@ -48,14 +48,12 @@ async fn play_ranking_match(selected_bots: Vec<Bot>, db_pool: DbPool) {
players.push(player);
}
- let mut run_match = RunMatch::from_players(players);
- run_match
- .store_in_database(&db_conn)
- .expect("could not store match in db");
- run_match
- .spawn(db_pool.clone())
+ let (_, handle) = RunMatch::from_players(players)
+ .run(db_pool.clone())
.await
- .expect("running match failed");
+ .expect("failed to run match");
+ // wait for match to complete, so that only one ranking match can be running
+ let _outcome = handle.await;
}
fn recalculate_ratings(db_conn: &PgConnection) -> QueryResult<()> {