diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-05-17 21:13:29 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-05-17 21:13:29 +0200 |
commit | 30de8107b499741808150db61abecd623bf1581b (patch) | |
tree | 8184324e170dc50cbaf1003588fa1df136454c1d /planetwars-server/src/routes/bots.rs | |
parent | a7d56ba0f54273920743109fe1a6541030f3c003 (diff) | |
download | planetwars.dev-30de8107b499741808150db61abecd623bf1581b.tar.xz planetwars.dev-30de8107b499741808150db61abecd623bf1581b.zip |
implement leaderboard endpoint
Diffstat (limited to 'planetwars-server/src/routes/bots.rs')
-rw-r--r-- | planetwars-server/src/routes/bots.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/planetwars-server/src/routes/bots.rs b/planetwars-server/src/routes/bots.rs index 2cdea2a..3bbaa1a 100644 --- a/planetwars-server/src/routes/bots.rs +++ b/planetwars-server/src/routes/bots.rs @@ -12,6 +12,7 @@ use std::path::PathBuf; use thiserror; use crate::db::bots::{self, CodeBundle}; +use crate::db::ratings::{RankedBot, self}; use crate::db::users::User; use crate::modules::bots::save_code_bundle; use crate::{DatabaseConnection, BOTS_DIR}; @@ -170,6 +171,12 @@ pub async fn list_bots(conn: DatabaseConnection) -> Result<Json<Vec<Bot>>, Statu .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) } +pub async fn get_ranking(conn: DatabaseConnection) -> Result<Json<Vec<RankedBot>>, StatusCode> { + ratings::get_bot_ranking(&conn) + .map(Json) + .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) +} + // TODO: currently this only implements the happy flow pub async fn upload_code_multipart( conn: DatabaseConnection, |