aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-30 16:20:29 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-30 16:23:35 +0100
commitf429adb4f8607ef9b8b8e2c9fa3634c5f39a5602 (patch)
treede4209bf4e00c01f70263deea148c56a8dd96436 /planetwars-server/src/db
parent00d31df58d0ea68b11600d98ebf53150a2a0cb88 (diff)
downloadplanetwars.dev-f429adb4f8607ef9b8b8e2c9fa3634c5f39a5602.tar.xz
planetwars.dev-f429adb4f8607ef9b8b8e2c9fa3634c5f39a5602.zip
allow filtering map in bot matches
Diffstat (limited to 'planetwars-server/src/db')
-rw-r--r--planetwars-server/src/db/match_queries.rs5
-rw-r--r--planetwars-server/src/db/matches.rs2
2 files changed, 7 insertions, 0 deletions
diff --git a/planetwars-server/src/db/match_queries.rs b/planetwars-server/src/db/match_queries.rs
index f9f8140..029a657 100644
--- a/planetwars-server/src/db/match_queries.rs
+++ b/planetwars-server/src/db/match_queries.rs
@@ -12,6 +12,7 @@ pub struct ListBotMatches {
pub outcome: Option<BotMatchOutcome>,
pub opponent_id: Option<i32>,
+ pub map_id: Option<i32>,
// pagination options
pub before: Option<NaiveDateTime>,
@@ -55,6 +56,10 @@ impl QueryFragment<Pg> for ListBotMatches {
}
out.push_sql(" WHERE matches.state = 'finished' AND matches.is_public = true");
+ if let Some(map_id) = self.map_id.as_ref() {
+ out.push_sql(" AND matches.map_id = ");
+ out.push_bind_param::<Integer, _>(map_id)?;
+ }
if let Some(outcome) = self.outcome.as_ref() {
match outcome {
BotMatchOutcome::Win => {
diff --git a/planetwars-server/src/db/matches.rs b/planetwars-server/src/db/matches.rs
index c86f332..2aff44b 100644
--- a/planetwars-server/src/db/matches.rs
+++ b/planetwars-server/src/db/matches.rs
@@ -176,6 +176,7 @@ pub fn list_public_matches(
pub fn list_bot_matches(
bot_id: i32,
opponent_id: Option<i32>,
+ map_id: Option<i32>,
outcome: Option<BotMatchOutcome>,
had_errors: Option<bool>,
amount: i64,
@@ -188,6 +189,7 @@ pub fn list_bot_matches(
outcome,
had_errors,
opponent_id,
+ map_id,
before,
after,
amount,