diff options
Diffstat (limited to 'makima/src/server/handlers/contracts.rs')
| -rw-r--r-- | makima/src/server/handlers/contracts.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/makima/src/server/handlers/contracts.rs b/makima/src/server/handlers/contracts.rs index 8c8cabf..54bae71 100644 --- a/makima/src/server/handlers/contracts.rs +++ b/makima/src/server/handlers/contracts.rs @@ -574,6 +574,35 @@ pub async fn update_contract( "status": &contract.status, }), ).await; + + // If contract is part of a chain, progress the chain + if let Some(chain_id) = contract.chain_id { + let pool_clone = pool.clone(); + let owner_id = auth.owner_id; + tokio::spawn(async move { + match repository::progress_chain(&pool_clone, chain_id, owner_id).await { + Ok(result) => { + if !result.contracts_created.is_empty() { + tracing::info!( + chain_id = %chain_id, + contracts_created = ?result.contracts_created, + "Chain progressed - created new contracts" + ); + } + if result.chain_completed { + tracing::info!(chain_id = %chain_id, "Chain completed"); + } + } + Err(e) => { + tracing::error!( + chain_id = %chain_id, + error = %e, + "Failed to progress chain after contract completion" + ); + } + } + }); + } } // Get summary with counts |
