From 30de8107b499741808150db61abecd623bf1581b Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 17 May 2022 21:13:29 +0200 Subject: implement leaderboard endpoint --- planetwars-server/src/routes/bots.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'planetwars-server/src/routes/bots.rs') 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>, Statu .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) } +pub async fn get_ranking(conn: DatabaseConnection) -> Result>, 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, -- cgit v1.2.3