diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-10-12 22:52:15 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-10-12 22:52:15 +0200 |
commit | ae57359353cf31ff374a8932999742920878bf00 (patch) | |
tree | 0db27d394a2a61a5cc94e73014c82954829c1338 /planetwars-server/src/routes/matches.rs | |
parent | ed016773b112460ebbf0ff023b0915545229ed41 (diff) | |
download | planetwars.dev-ae57359353cf31ff374a8932999742920878bf00.tar.xz planetwars.dev-ae57359353cf31ff374a8932999742920878bf00.zip |
upgrade to diesel 2.0
Diffstat (limited to 'planetwars-server/src/routes/matches.rs')
-rw-r--r-- | planetwars-server/src/routes/matches.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs index 1d7403c..3ad10cf 100644 --- a/planetwars-server/src/routes/matches.rs +++ b/planetwars-server/src/routes/matches.rs @@ -56,7 +56,7 @@ pub struct ListMatchesResponse { pub async fn list_recent_matches( Query(params): Query<ListRecentMatchesParams>, - conn: DatabaseConnection, + mut conn: DatabaseConnection, ) -> Result<Json<ListMatchesResponse>, StatusCode> { let requested_count = std::cmp::min( params.count.unwrap_or(DEFAULT_NUM_RETURNED_MATCHES), @@ -68,7 +68,7 @@ pub async fn list_recent_matches( let matches_result = match params.bot { Some(bot_name) => { - let bot = db::bots::find_bot_by_name(&bot_name, &conn) + let bot = db::bots::find_bot_by_name(&bot_name, &mut conn) .map_err(|_| StatusCode::BAD_REQUEST)?; matches::list_bot_matches( bot.id, @@ -76,10 +76,10 @@ pub async fn list_recent_matches( count, params.before, params.after, - &conn, + &mut conn, ) } - None => matches::list_public_matches(count, params.before, params.after, &conn), + None => matches::list_public_matches(count, params.before, params.after, &mut conn), }; let mut matches = matches_result.map_err(|_| StatusCode::BAD_REQUEST)?; @@ -119,9 +119,9 @@ pub fn match_data_to_api(data: matches::FullMatchData) -> ApiMatch { pub async fn get_match_data( Path(match_id): Path<i32>, - conn: DatabaseConnection, + mut conn: DatabaseConnection, ) -> Result<Json<ApiMatch>, StatusCode> { - let match_data = matches::find_match(match_id, &conn) + let match_data = matches::find_match(match_id, &mut conn) .map_err(|_| StatusCode::NOT_FOUND) .map(match_data_to_api)?; Ok(Json(match_data)) @@ -129,11 +129,11 @@ pub async fn get_match_data( pub async fn get_match_log( Path(match_id): Path<i32>, - conn: DatabaseConnection, + mut conn: DatabaseConnection, Extension(config): Extension<Arc<GlobalConfig>>, ) -> Result<Vec<u8>, StatusCode> { let match_base = - matches::find_match_base(match_id, &conn).map_err(|_| StatusCode::NOT_FOUND)?; + matches::find_match_base(match_id, &mut conn).map_err(|_| StatusCode::NOT_FOUND)?; let log_path = PathBuf::from(&config.match_logs_directory).join(&match_base.log_path); let log_contents = std::fs::read(log_path).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; Ok(log_contents) |