From b51b7a331ddfd93675e93d88cf267494b9c1b083 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Fri, 14 Oct 2022 14:06:22 +0200 Subject: allow filtering for had_errors --- planetwars-server/src/db/match_queries.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'planetwars-server/src/db/match_queries.rs') diff --git a/planetwars-server/src/db/match_queries.rs b/planetwars-server/src/db/match_queries.rs index 2e89706..999802f 100644 --- a/planetwars-server/src/db/match_queries.rs +++ b/planetwars-server/src/db/match_queries.rs @@ -8,9 +8,12 @@ use diesel::{PgConnection, QueryResult, RunQueryDsl}; pub struct ListBotMatches { pub bot_id: i32, - pub opponent_id: Option, + pub had_errors: Option, pub outcome: Option, + pub opponent_id: Option, + + // pagination options pub before: Option, pub after: Option, pub amount: i64, @@ -29,6 +32,12 @@ impl QueryFragment for ListBotMatches { "WHERE bot_id = " )); out.push_bind_param::(&self.bot_id)?; + + if let Some(had_errors) = self.had_errors.as_ref() { + out.push_sql(" AND match_players.had_errors = "); + out.push_bind_param::(had_errors)?; + } + out.push_sql(") main_player ON matches.id = main_player.match_id"); if let Some(opponent_id) = self.opponent_id.as_ref() { @@ -40,6 +49,7 @@ impl QueryFragment for ListBotMatches { "WHERE bot_id = " )); out.push_bind_param::(opponent_id)?; + out.push_sql(") other_player ON matches.id = other_player.match_id"); } -- cgit v1.2.3