From f84a7f2d820f6f432be2b1d78d6bf833b5b19380 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 16 Jan 2026 17:07:44 +0000 Subject: Fixup: fix history call and try to start pending tasks when a daemon is available --- makima/src/db/repository.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'makima/src/db/repository.rs') diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index cb9d52f..2b069d5 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -789,6 +789,27 @@ pub async fn list_tasks_by_contract( .await } +/// Get pending tasks for a contract (non-supervisor tasks only). +pub async fn get_pending_tasks_for_contract( + pool: &PgPool, + contract_id: Uuid, + owner_id: Uuid, +) -> Result, sqlx::Error> { + sqlx::query_as::<_, Task>( + r#" + SELECT * FROM tasks + WHERE contract_id = $1 AND owner_id = $2 + AND status = 'pending' + AND is_supervisor = false + ORDER BY priority DESC, created_at ASC + "#, + ) + .bind(contract_id) + .bind(owner_id) + .fetch_all(pool) + .await +} + /// Update a task by ID with optimistic locking. pub async fn update_task( pool: &PgPool, -- cgit v1.2.3