aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/routes/matches.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-12 21:08:00 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-12 21:08:00 +0200
commited016773b112460ebbf0ff023b0915545229ed41 (patch)
tree0d98d2af735fd01c3e0634c68e46490e34bacd99 /planetwars-server/src/routes/matches.rs
parent19b9a6ea1b8a36ae2301ffbc95cf2f54bf7fa77f (diff)
downloadplanetwars.dev-ed016773b112460ebbf0ff023b0915545229ed41.tar.xz
planetwars.dev-ed016773b112460ebbf0ff023b0915545229ed41.zip
filter matches for outcome
Diffstat (limited to 'planetwars-server/src/routes/matches.rs')
-rw-r--r--planetwars-server/src/routes/matches.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs
index 10b4507..1d7403c 100644
--- a/planetwars-server/src/routes/matches.rs
+++ b/planetwars-server/src/routes/matches.rs
@@ -10,7 +10,7 @@ use std::{path::PathBuf, sync::Arc};
use crate::{
db::{
self,
- matches::{self, MatchState},
+ matches::{self, BotMatchOutcome, MatchState},
},
DatabaseConnection, GlobalConfig,
};
@@ -42,6 +42,7 @@ pub struct ListRecentMatchesParams {
after: Option<NaiveDateTime>,
bot: Option<String>,
+ outcome: Option<BotMatchOutcome>,
}
const MAX_NUM_RETURNED_MATCHES: usize = 100;
@@ -69,7 +70,14 @@ pub async fn list_recent_matches(
Some(bot_name) => {
let bot = db::bots::find_bot_by_name(&bot_name, &conn)
.map_err(|_| StatusCode::BAD_REQUEST)?;
- matches::list_bot_matches(bot.id, count, params.before, params.after, &conn)
+ matches::list_bot_matches(
+ bot.id,
+ params.outcome,
+ count,
+ params.before,
+ params.after,
+ &conn,
+ )
}
None => matches::list_public_matches(count, params.before, params.after, &conn),
};