From ad5af0f7677c73fc159a3036b9479d1d847adf97 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 13 Feb 2026 20:35:22 +0000 Subject: Directive page improvements --- makima/src/db/repository.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'makima/src/db') diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index 8923f97..e288eba 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -4993,11 +4993,20 @@ pub async fn list_directives_for_owner( d.id, d.owner_id, d.title, d.goal, d.status, d.repository_url, d.orchestrator_task_id, d.pr_url, d.completion_task_id, d.version, d.created_at, d.updated_at, - COALESCE((SELECT COUNT(*) FROM directive_steps WHERE directive_id = d.id), 0) as total_steps, - COALESCE((SELECT COUNT(*) FROM directive_steps WHERE directive_id = d.id AND status = 'completed'), 0) as completed_steps, - COALESCE((SELECT COUNT(*) FROM directive_steps WHERE directive_id = d.id AND status = 'running'), 0) as running_steps, - COALESCE((SELECT COUNT(*) FROM directive_steps WHERE directive_id = d.id AND status = 'failed'), 0) as failed_steps + COALESCE(s.total_steps, 0) as total_steps, + COALESCE(s.completed_steps, 0) as completed_steps, + COALESCE(s.running_steps, 0) as running_steps, + COALESCE(s.failed_steps, 0) as failed_steps FROM directives d + LEFT JOIN LATERAL ( + SELECT + COUNT(*) as total_steps, + COUNT(*) FILTER (WHERE status = 'completed') as completed_steps, + COUNT(*) FILTER (WHERE status = 'running') as running_steps, + COUNT(*) FILTER (WHERE status = 'failed') as failed_steps + FROM directive_steps + WHERE directive_id = d.id + ) s ON true WHERE d.owner_id = $1 ORDER BY d.created_at DESC "#, -- cgit v1.2.3