summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers/contract_daemon.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/server/handlers/contract_daemon.rs')
-rw-r--r--makima/src/server/handlers/contract_daemon.rs38
1 files changed, 7 insertions, 31 deletions
diff --git a/makima/src/server/handlers/contract_daemon.rs b/makima/src/server/handlers/contract_daemon.rs
index 5b23831..5f56f06 100644
--- a/makima/src/server/handlers/contract_daemon.rs
+++ b/makima/src/server/handlers/contract_daemon.rs
@@ -15,7 +15,7 @@ use utoipa::ToSchema;
use uuid::Uuid;
use crate::db::{models::FileSummary, repository};
-use crate::llm::phase_guidance::{self, FileInfo, PhaseChecklist, TaskInfo};
+use crate::llm::phase_guidance::{self, PhaseChecklist, TaskInfo};
use crate::server::auth::Authenticated;
use crate::server::messages::ApiError;
use crate::server::state::SharedState;
@@ -242,28 +242,14 @@ pub async fn get_contract_checklist(
}
};
- // Get files for this contract
- let files = match repository::list_files_in_contract(pool, id, auth.owner_id).await {
- Ok(f) => f
- .into_iter()
- .map(|f| FileInfo {
- id: f.id,
- name: f.name,
- contract_phase: f.contract_phase,
- })
- .collect::<Vec<_>>(),
- Err(e) => {
- tracing::warn!("Failed to get files for contract {}: {}", id, e);
- Vec::new()
- }
- };
+ // Get completed deliverables for the current phase
+ let completed_deliverables = contract.get_completed_deliverables(&contract.phase);
// Get tasks for this contract
let tasks = match repository::list_tasks_in_contract(pool, id, auth.owner_id).await {
Ok(t) => t
.into_iter()
.map(|t| TaskInfo {
- id: t.id,
name: t.name,
status: t.status,
})
@@ -280,7 +266,7 @@ pub async fn get_contract_checklist(
Err(_) => false,
};
- let checklist = phase_guidance::get_phase_checklist_for_type(&contract.phase, &files, &tasks, has_repository, &contract.contract_type);
+ let checklist = phase_guidance::get_phase_checklist_for_type(&contract.phase, &completed_deliverables, &tasks, has_repository, &contract.contract_type);
Json(checklist).into_response()
}
@@ -463,24 +449,14 @@ pub async fn get_suggest_action(
}
};
- // Get files and tasks for checklist
- let files = repository::list_files_in_contract(pool, id, auth.owner_id)
- .await
- .unwrap_or_default()
- .into_iter()
- .map(|f| FileInfo {
- id: f.id,
- name: f.name,
- contract_phase: f.contract_phase,
- })
- .collect::<Vec<_>>();
+ // Get completed deliverables and tasks for checklist
+ let completed_deliverables = contract.get_completed_deliverables(&contract.phase);
let tasks = repository::list_tasks_in_contract(pool, id, auth.owner_id)
.await
.unwrap_or_default()
.into_iter()
.map(|t| TaskInfo {
- id: t.id,
name: t.name,
status: t.status,
})
@@ -491,7 +467,7 @@ pub async fn get_suggest_action(
.map(|r| !r.is_empty())
.unwrap_or(false);
- let checklist = phase_guidance::get_phase_checklist_for_type(&contract.phase, &files, &tasks, has_repository, &contract.contract_type);
+ let checklist = phase_guidance::get_phase_checklist_for_type(&contract.phase, &completed_deliverables, &tasks, has_repository, &contract.contract_type);
// Determine suggested action based on checklist
let (action, description) = if !checklist.suggestions.is_empty() {