finish games when finishing idle instances
This commit is contained in:
parent
36b5b5088b
commit
9ed191d9ae
@ -804,7 +804,7 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
fn finish(mut self) -> Game {
|
||||
pub fn finish(mut self) -> Game {
|
||||
self.phase = Phase::Finished;
|
||||
// self.log.push(format!("Game finished."));
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ use pg::{
|
||||
PgPool,
|
||||
|
||||
games_need_upkeep,
|
||||
game_get,
|
||||
game_update,
|
||||
game_write,
|
||||
game_delete,
|
||||
@ -157,6 +158,12 @@ fn fetch_instances(mut tx: Transaction) -> Result<Transaction, Error> {
|
||||
}
|
||||
|
||||
for mut instance in instances_idle(&mut tx)? {
|
||||
if let Some(game_id) = instance.current_game_id() {
|
||||
let mut game = game_get(&mut tx, game_id)?;
|
||||
game = game.finish();
|
||||
game_update(&mut tx, &game)?;
|
||||
}
|
||||
|
||||
instance.finish();
|
||||
instance_update(&mut tx, instance)?;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user