Transition a task to Running status, setting `started_at` to now.
(
&self,
id: &str,
)
| 387 | |
| 388 | /// Transition a task to Running status, setting `started_at` to now. |
| 389 | pub async fn mark_running( |
| 390 | &self, |
| 391 | id: &str, |
| 392 | ) -> Result<Task, Box<dyn std::error::Error + Send + Sync>> { |
| 393 | let conn = Arc::clone(&self.conn); |
| 394 | let id = id.to_string(); |
| 395 | tokio::task::spawn_blocking(move || { |
| 396 | let conn = conn.lock().map_err(|e| format!("Lock error: {e}"))?; |
| 397 | let now = chrono::Utc::now().to_rfc3339(); |
| 398 | let rows_affected = conn.execute( |
| 399 | "UPDATE tasks SET status = 'RUNNING', started_at = ?1 WHERE id = ?2", |
| 400 | rusqlite::params![now, id], |
| 401 | )?; |
| 402 | if rows_affected == 0 { |
| 403 | return Err("Task not found".into()); |
| 404 | } |
| 405 | read_task_by_id(&conn, &id) |
| 406 | }) |
| 407 | .await? |
| 408 | } |
| 409 | |
| 410 | /// Transition a task to Complete status, setting `completed_at` to now and `branch_name`. |
| 411 | /// |