summaryrefslogtreecommitdiff
path: root/makima/src/db/repository.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/db/repository.rs')
-rw-r--r--makima/src/db/repository.rs21
1 files changed, 21 insertions, 0 deletions
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<Vec<Task>, 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,