From ebd01757e8676c081b318e67283dd56089a7db6b Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 15 Feb 2022 19:54:29 +0100 Subject: play matches async --- planetwars-server/src/db/matches.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'planetwars-server/src/db/matches.rs') diff --git a/planetwars-server/src/db/matches.rs b/planetwars-server/src/db/matches.rs index efaa1eb..6444bf6 100644 --- a/planetwars-server/src/db/matches.rs +++ b/planetwars-server/src/db/matches.rs @@ -1,6 +1,6 @@ pub use crate::db_types::MatchState; use chrono::NaiveDateTime; -use diesel::{BelongingToDsl, QueryDsl, RunQueryDsl}; +use diesel::{BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{Connection, GroupedBy, PgConnection, QueryResult}; use crate::schema::{match_players, matches}; @@ -120,3 +120,10 @@ pub fn find_match(id: i32, conn: &PgConnection) -> QueryResult { pub fn find_mach_base(id: i32, conn: &PgConnection) -> QueryResult { matches::table.find(id).get_result::(conn) } + +pub fn set_match_state(id: i32, match_state: MatchState, conn: &PgConnection) -> QueryResult<()> { + diesel::update(matches::table.find(id)) + .set(matches::state.eq(match_state)) + .execute(conn)?; + Ok(()) +} -- cgit v1.2.3