diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-02-15 19:54:29 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-02-15 19:54:29 +0100 |
commit | ebd01757e8676c081b318e67283dd56089a7db6b (patch) | |
tree | 727de39204bd5433371b77592e6078b3a6abf922 /planetwars-server/src/db/matches.rs | |
parent | c7f4da07c1bb3b8a52a596e7c2573c7bf3ce7b79 (diff) | |
download | planetwars.dev-ebd01757e8676c081b318e67283dd56089a7db6b.tar.xz planetwars.dev-ebd01757e8676c081b318e67283dd56089a7db6b.zip |
play matches async
Diffstat (limited to 'planetwars-server/src/db/matches.rs')
-rw-r--r-- | planetwars-server/src/db/matches.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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<MatchData> { pub fn find_mach_base(id: i32, conn: &PgConnection) -> QueryResult<MatchBase> { matches::table.find(id).get_result::<MatchBase>(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(()) +} |