diff options
Diffstat (limited to 'planetwars-server/src/lib.rs')
| -rw-r--r-- | planetwars-server/src/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/planetwars-server/src/lib.rs b/planetwars-server/src/lib.rs index e16b232..fa1af8d 100644 --- a/planetwars-server/src/lib.rs +++ b/planetwars-server/src/lib.rs @@ -94,11 +94,9 @@ pub async fn seed_simplebot(config: &GlobalConfig, pool: &ConnectionPool) { pub type DbPool = Pool<DieselConnectionManager<PgConnection>>; -pub async fn prepare_db(config: &GlobalConfig) -> DbPool { +pub async fn create_db_pool(config: &GlobalConfig) -> DbPool { let manager = DieselConnectionManager::<PgConnection>::new(&config.database_url); - let pool = bb8::Pool::builder().build(manager).await.unwrap(); - seed_simplebot(config, &pool).await; - pool + bb8::Pool::builder().build(manager).await.unwrap() } // create all directories required for further operation @@ -129,12 +127,13 @@ pub fn api() -> Router { "/bots/:bot_name/upload", post(routes::bots::upload_code_multipart), ) - .route("/matches", get(routes::matches::list_matches)) + .route("/matches", get(routes::matches::list_recent_matches)) .route("/matches/:match_id", get(routes::matches::get_match_data)) .route( "/matches/:match_id/log", get(routes::matches::get_match_log), ) + .route("/maps", get(routes::maps::list_maps)) .route("/leaderboard", get(routes::bots::get_ranking)) .route("/submit_bot", post(routes::demo::submit_bot)) .route("/save_bot", post(routes::bots::save_bot)) @@ -165,7 +164,8 @@ async fn run_registry(config: Arc<GlobalConfig>, db_pool: DbPool) { pub async fn run_app() { let global_config = Arc::new(get_config().unwrap()); - let db_pool = prepare_db(&global_config).await; + let db_pool = create_db_pool(&global_config).await; + seed_simplebot(&global_config, &db_pool).await; init_directories(&global_config).unwrap(); if global_config.ranker_enabled { |
