summaryrefslogtreecommitdiff
path: root/makima/src
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-13 20:35:22 +0000
committersoryu <soryu@soryu.co>2026-02-13 20:35:22 +0000
commitad5af0f7677c73fc159a3036b9479d1d847adf97 (patch)
tree718633b10a12d1c36f51a903a1f4149c5c6677f7 /makima/src
parentc19da4baf036a395c50dfbd19f6a1a91a69229a7 (diff)
downloadsoryu-ad5af0f7677c73fc159a3036b9479d1d847adf97.tar.gz
soryu-ad5af0f7677c73fc159a3036b9479d1d847adf97.zip
Directive page improvements
Diffstat (limited to 'makima/src')
-rw-r--r--makima/src/db/repository.rs17
1 files changed, 13 insertions, 4 deletions
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
"#,