refactor(storage): extract task_row_from helper — consistent with transcript_row_from pattern

This commit is contained in:
2026-04-19 10:37:55 +01:00
parent 35efed53e5
commit 6f264d8bec

View File

@@ -293,18 +293,7 @@ pub async fn list_tasks(pool: &SqlitePool) -> Result<Vec<TaskRow>> {
Ok(rows
.into_iter()
.map(|r| TaskRow {
id: r.get("id"),
text: r.get("text"),
bucket: r.get("bucket"),
list_id: r.get("list_id"),
effort: r.get("effort"),
done: r.get("done"),
done_at: r.get("done_at"),
created_at: r.get("created_at"),
source_transcript_id: r.get("source_transcript_id"),
parent_task_id: r.get("parent_task_id"),
})
.map(task_row_from)
.collect())
}
@@ -318,18 +307,7 @@ pub async fn get_task_by_id(pool: &SqlitePool, id: &str) -> Result<Option<TaskRo
.await
.map_err(|e| KonError::StorageError(format!("Get task failed: {e}")))?;
Ok(row.map(|r| TaskRow {
id: r.get("id"),
text: r.get("text"),
bucket: r.get("bucket"),
list_id: r.get("list_id"),
effort: r.get("effort"),
done: r.get("done"),
done_at: r.get("done_at"),
created_at: r.get("created_at"),
source_transcript_id: r.get("source_transcript_id"),
parent_task_id: r.get("parent_task_id"),
}))
Ok(row.map(task_row_from))
}
pub async fn insert_subtask(
@@ -361,18 +339,7 @@ pub async fn list_subtasks(pool: &SqlitePool, parent_id: &str) -> Result<Vec<Tas
.await
.map_err(|e| KonError::StorageError(format!("List subtasks failed: {e}")))?;
Ok(rows.into_iter().map(|r| TaskRow {
id: r.get("id"),
text: r.get("text"),
bucket: r.get("bucket"),
list_id: r.get("list_id"),
effort: r.get("effort"),
done: r.get("done"),
done_at: r.get("done_at"),
created_at: r.get("created_at"),
source_transcript_id: r.get("source_transcript_id"),
parent_task_id: r.get("parent_task_id"),
}).collect())
Ok(rows.into_iter().map(task_row_from).collect())
}
/// Mark a subtask done. If all siblings are now done, auto-complete the parent.
@@ -508,6 +475,21 @@ fn transcript_row_from(r: &sqlx::sqlite::SqliteRow) -> TranscriptRow {
}
}
fn task_row_from(r: sqlx::sqlite::SqliteRow) -> TaskRow {
TaskRow {
id: r.get("id"),
text: r.get("text"),
bucket: r.get("bucket"),
list_id: r.get("list_id"),
effort: r.get("effort"),
done: r.get("done"),
done_at: r.get("done_at"),
created_at: r.get("created_at"),
source_transcript_id: r.get("source_transcript_id"),
parent_task_id: r.get("parent_task_id"),
}
}
// --- Error Logging ---
/// Log a structured error to the `error_log` table.