aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db/matches.rs
diff options
context:
space:
mode:
Diffstat (limited to 'planetwars-server/src/db/matches.rs')
-rw-r--r--planetwars-server/src/db/matches.rs9
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(())
+}