summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers/contracts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/server/handlers/contracts.rs')
-rw-r--r--makima/src/server/handlers/contracts.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/makima/src/server/handlers/contracts.rs b/makima/src/server/handlers/contracts.rs
index afca3d7..684ab2b 100644
--- a/makima/src/server/handlers/contracts.rs
+++ b/makima/src/server/handlers/contracts.rs
@@ -340,6 +340,22 @@ pub async fn create_contract(
);
}
+ // Record history event for contract creation
+ let _ = repository::record_history_event(
+ pool,
+ auth.owner_id,
+ Some(contract.id),
+ None,
+ "contract",
+ Some("created"),
+ Some(&contract.phase),
+ serde_json::json!({
+ "name": &contract.name,
+ "type": &contract.contract_type,
+ "description": &contract.description,
+ }),
+ ).await;
+
// Get the summary version with counts
match repository::get_contract_summary_for_owner(pool, contract.id, auth.owner_id).await
{
@@ -474,6 +490,21 @@ pub async fn update_contract(
tokio::spawn(async move {
cleanup_contract_worktrees(&pool_clone, &state_clone, contract_id).await;
});
+
+ // Record history event for contract completion
+ let _ = repository::record_history_event(
+ pool,
+ auth.owner_id,
+ Some(contract.id),
+ None,
+ "contract",
+ Some("completed"),
+ Some(&contract.phase),
+ serde_json::json!({
+ "name": &contract.name,
+ "status": &contract.status,
+ }),
+ ).await;
}
// Get summary with counts
@@ -1255,6 +1286,21 @@ pub async fn change_phase(
}
}
+ // Record history event for phase change
+ let _ = repository::record_history_event(
+ pool,
+ auth.owner_id,
+ Some(contract.id),
+ None,
+ "phase",
+ Some("changed"),
+ Some(&contract.phase),
+ serde_json::json!({
+ "contractName": &contract.name,
+ "newPhase": &contract.phase,
+ }),
+ ).await;
+
// Get summary with counts
match repository::get_contract_summary_for_owner(pool, contract.id, auth.owner_id).await
{