I've successfully removed the unused DB query methods from the crates/db crate. Here's a summary of what was removed: (#1501)
## Summary of Removed Unused Methods ### `crates/db/src/models/task.rs` (2 methods) - `Task::find_by_id_and_project_id` (was at line 241) - `Task::exists` (was at line 461) ### `crates/db/src/models/project.rs` (2 methods) - `Project::find_by_remote_project_id` (was at line 152) - `Project::exists` (was at line 368) ### `crates/db/src/models/task_attempt.rs` (1 method) - `TaskAttempt::find_by_task_id_with_project` (was at line 266) ### `crates/db/src/models/execution_process.rs` (3 methods) - `ExecutionProcess::count_later_than` (was at line 172) - `ExecutionProcess::delete_by_task_attempt_id` (was at line 482) - `ExecutionProcess::set_restore_boundary` (was at line 505) ### `crates/db/src/models/executor_session.rs` (5 methods) - `ExecutorSession::find_by_id` (was at line 37) - `ExecutorSession::find_by_task_attempt_id` (was at line 83) - `ExecutorSession::find_by_session_id` (was at line 107) - `ExecutorSession::update_prompt` (was at line 199) - `ExecutorSession::delete_by_task_attempt_id` (was at line 241) ### `crates/db/src/models/execution_process_logs.rs` (1 method) - `ExecutionProcessLogs::serialize_logs` (was at line 51) **Total: 14 unused methods removed** The build passes successfully (`cargo check --workspace`), confirming all changes are valid.
This commit is contained in:
committed by
GitHub
parent
2366e4ad23
commit
9688734e99
@@ -168,25 +168,6 @@ impl ExecutionProcess {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Count processes created after the given boundary process
|
|
||||||
pub async fn count_later_than(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
task_attempt_id: Uuid,
|
|
||||||
boundary_process_id: Uuid,
|
|
||||||
) -> Result<i64, sqlx::Error> {
|
|
||||||
let cnt = sqlx::query_scalar!(
|
|
||||||
r#"SELECT COUNT(1) as "count!:_" FROM execution_processes
|
|
||||||
WHERE task_attempt_id = $1
|
|
||||||
AND created_at > (SELECT created_at FROM execution_processes WHERE id = $2)"#,
|
|
||||||
task_attempt_id,
|
|
||||||
boundary_process_id
|
|
||||||
)
|
|
||||||
.fetch_one(pool)
|
|
||||||
.await
|
|
||||||
.unwrap_or(0i64);
|
|
||||||
Ok(cnt)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Find execution process by rowid
|
/// Find execution process by rowid
|
||||||
pub async fn find_by_rowid(pool: &SqlitePool, rowid: i64) -> Result<Option<Self>, sqlx::Error> {
|
pub async fn find_by_rowid(pool: &SqlitePool, rowid: i64) -> Result<Option<Self>, sqlx::Error> {
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
@@ -479,19 +460,6 @@ impl ExecutionProcess {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_by_task_attempt_id(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
task_attempt_id: Uuid,
|
|
||||||
) -> Result<(), sqlx::Error> {
|
|
||||||
sqlx::query!(
|
|
||||||
"DELETE FROM execution_processes WHERE task_attempt_id = $1",
|
|
||||||
task_attempt_id
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn executor_action(&self) -> Result<&ExecutorAction, anyhow::Error> {
|
pub fn executor_action(&self) -> Result<&ExecutorAction, anyhow::Error> {
|
||||||
match &self.executor_action.0 {
|
match &self.executor_action.0 {
|
||||||
ExecutorActionField::ExecutorAction(action) => Ok(action),
|
ExecutorActionField::ExecutorAction(action) => Ok(action),
|
||||||
@@ -501,28 +469,6 @@ impl ExecutionProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set restore boundary: drop processes newer than the specified process, undrop older/equal
|
|
||||||
pub async fn set_restore_boundary(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
task_attempt_id: Uuid,
|
|
||||||
boundary_process_id: Uuid,
|
|
||||||
) -> Result<(), sqlx::Error> {
|
|
||||||
// Monotonic drop: only mark newer records as dropped; never undrop.
|
|
||||||
sqlx::query!(
|
|
||||||
r#"UPDATE execution_processes
|
|
||||||
SET dropped = TRUE
|
|
||||||
WHERE task_attempt_id = $1
|
|
||||||
AND created_at > (SELECT created_at FROM execution_processes WHERE id = $2)
|
|
||||||
AND dropped = FALSE
|
|
||||||
"#,
|
|
||||||
task_attempt_id,
|
|
||||||
boundary_process_id
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Soft-drop processes at and after the specified boundary (inclusive)
|
/// Soft-drop processes at and after the specified boundary (inclusive)
|
||||||
pub async fn drop_at_and_after(
|
pub async fn drop_at_and_after(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
|
|||||||
@@ -47,17 +47,6 @@ impl ExecutionProcessLogs {
|
|||||||
Ok(messages)
|
Ok(messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert Vec<LogMsg> to JSONL format
|
|
||||||
pub fn serialize_logs(messages: &[LogMsg]) -> Result<String, serde_json::Error> {
|
|
||||||
let mut jsonl = String::new();
|
|
||||||
for msg in messages {
|
|
||||||
let line = serde_json::to_string(msg)?;
|
|
||||||
jsonl.push_str(&line);
|
|
||||||
jsonl.push('\n');
|
|
||||||
}
|
|
||||||
Ok(jsonl)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Append a JSONL line to the logs for an execution process
|
/// Append a JSONL line to the logs for an execution process
|
||||||
pub async fn append_log_line(
|
pub async fn append_log_line(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
|
|||||||
@@ -32,28 +32,6 @@ pub struct UpdateExecutorSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ExecutorSession {
|
impl ExecutorSession {
|
||||||
/// Find executor session by ID
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn find_by_id(pool: &SqlitePool, id: Uuid) -> Result<Option<Self>, sqlx::Error> {
|
|
||||||
sqlx::query_as!(
|
|
||||||
ExecutorSession,
|
|
||||||
r#"SELECT
|
|
||||||
id as "id!: Uuid",
|
|
||||||
task_attempt_id as "task_attempt_id!: Uuid",
|
|
||||||
execution_process_id as "execution_process_id!: Uuid",
|
|
||||||
session_id,
|
|
||||||
prompt,
|
|
||||||
summary,
|
|
||||||
created_at as "created_at!: DateTime<Utc>",
|
|
||||||
updated_at as "updated_at!: DateTime<Utc>"
|
|
||||||
FROM executor_sessions
|
|
||||||
WHERE id = $1"#,
|
|
||||||
id
|
|
||||||
)
|
|
||||||
.fetch_optional(pool)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Find executor session by execution process ID
|
/// Find executor session by execution process ID
|
||||||
pub async fn find_by_execution_process_id(
|
pub async fn find_by_execution_process_id(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
@@ -78,57 +56,6 @@ impl ExecutorSession {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find all executor sessions for a task attempt
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn find_by_task_attempt_id(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
task_attempt_id: Uuid,
|
|
||||||
) -> Result<Vec<Self>, sqlx::Error> {
|
|
||||||
sqlx::query_as!(
|
|
||||||
ExecutorSession,
|
|
||||||
r#"SELECT
|
|
||||||
id as "id!: Uuid",
|
|
||||||
task_attempt_id as "task_attempt_id!: Uuid",
|
|
||||||
execution_process_id as "execution_process_id!: Uuid",
|
|
||||||
session_id,
|
|
||||||
prompt,
|
|
||||||
summary,
|
|
||||||
created_at as "created_at!: DateTime<Utc>",
|
|
||||||
updated_at as "updated_at!: DateTime<Utc>"
|
|
||||||
FROM executor_sessions
|
|
||||||
WHERE task_attempt_id = $1
|
|
||||||
ORDER BY created_at ASC"#,
|
|
||||||
task_attempt_id
|
|
||||||
)
|
|
||||||
.fetch_all(pool)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn find_by_session_id(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
session_id: &str,
|
|
||||||
) -> Result<Option<Self>, sqlx::Error> {
|
|
||||||
sqlx::query_as!(
|
|
||||||
ExecutorSession,
|
|
||||||
r#"SELECT
|
|
||||||
id as "id!: Uuid",
|
|
||||||
task_attempt_id as "task_attempt_id!: Uuid",
|
|
||||||
execution_process_id as "execution_process_id!: Uuid",
|
|
||||||
session_id,
|
|
||||||
prompt,
|
|
||||||
summary,
|
|
||||||
created_at as "created_at!: DateTime<Utc>",
|
|
||||||
updated_at as "updated_at!: DateTime<Utc>"
|
|
||||||
FROM executor_sessions
|
|
||||||
WHERE session_id = ?
|
|
||||||
ORDER BY updated_at DESC
|
|
||||||
LIMIT 1"#,
|
|
||||||
session_id
|
|
||||||
)
|
|
||||||
.fetch_optional(pool)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new executor session
|
/// Create a new executor session
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
@@ -194,28 +121,6 @@ impl ExecutorSession {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update executor session prompt
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn update_prompt(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
id: Uuid,
|
|
||||||
prompt: &str,
|
|
||||||
) -> Result<(), sqlx::Error> {
|
|
||||||
let now = Utc::now();
|
|
||||||
sqlx::query!(
|
|
||||||
r#"UPDATE executor_sessions
|
|
||||||
SET prompt = $1, updated_at = $2
|
|
||||||
WHERE id = $3"#,
|
|
||||||
prompt,
|
|
||||||
now,
|
|
||||||
id
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update executor session summary
|
/// Update executor session summary
|
||||||
pub async fn update_summary(
|
pub async fn update_summary(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
@@ -236,19 +141,4 @@ impl ExecutorSession {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete executor sessions for a task attempt (cleanup)
|
|
||||||
pub async fn delete_by_task_attempt_id(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
task_attempt_id: Uuid,
|
|
||||||
) -> Result<(), sqlx::Error> {
|
|
||||||
sqlx::query!(
|
|
||||||
"DELETE FROM executor_sessions WHERE task_attempt_id = $1",
|
|
||||||
task_attempt_id
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,32 +149,6 @@ impl Project {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_by_remote_project_id(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
remote_project_id: Uuid,
|
|
||||||
) -> Result<Option<Self>, sqlx::Error> {
|
|
||||||
sqlx::query_as!(
|
|
||||||
Project,
|
|
||||||
r#"SELECT id as "id!: Uuid",
|
|
||||||
name,
|
|
||||||
git_repo_path,
|
|
||||||
setup_script,
|
|
||||||
dev_script,
|
|
||||||
cleanup_script,
|
|
||||||
copy_files,
|
|
||||||
parallel_setup_script as "parallel_setup_script!: bool",
|
|
||||||
remote_project_id as "remote_project_id: Uuid",
|
|
||||||
created_at as "created_at!: DateTime<Utc>",
|
|
||||||
updated_at as "updated_at!: DateTime<Utc>"
|
|
||||||
FROM projects
|
|
||||||
WHERE remote_project_id = $1
|
|
||||||
LIMIT 1"#,
|
|
||||||
remote_project_id
|
|
||||||
)
|
|
||||||
.fetch_optional(pool)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn find_by_git_repo_path(
|
pub async fn find_by_git_repo_path(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
git_repo_path: &str,
|
git_repo_path: &str,
|
||||||
@@ -364,19 +338,4 @@ impl Project {
|
|||||||
.await?;
|
.await?;
|
||||||
Ok(result.rows_affected())
|
Ok(result.rows_affected())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn exists(pool: &SqlitePool, id: Uuid) -> Result<bool, sqlx::Error> {
|
|
||||||
let result = sqlx::query!(
|
|
||||||
r#"
|
|
||||||
SELECT COUNT(*) as "count!: i64"
|
|
||||||
FROM projects
|
|
||||||
WHERE id = $1
|
|
||||||
"#,
|
|
||||||
id
|
|
||||||
)
|
|
||||||
.fetch_one(pool)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(result.count > 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,23 +238,6 @@ ORDER BY t.created_at DESC"#,
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_by_id_and_project_id(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
id: Uuid,
|
|
||||||
project_id: Uuid,
|
|
||||||
) -> Result<Option<Self>, sqlx::Error> {
|
|
||||||
sqlx::query_as!(
|
|
||||||
Task,
|
|
||||||
r#"SELECT id as "id!: Uuid", project_id as "project_id!: Uuid", title, description, status as "status!: TaskStatus", parent_task_attempt as "parent_task_attempt: Uuid", shared_task_id as "shared_task_id: Uuid", created_at as "created_at!: DateTime<Utc>", updated_at as "updated_at!: DateTime<Utc>"
|
|
||||||
FROM tasks
|
|
||||||
WHERE id = $1 AND project_id = $2"#,
|
|
||||||
id,
|
|
||||||
project_id
|
|
||||||
)
|
|
||||||
.fetch_optional(pool)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn find_by_shared_task_id<'e, E>(
|
pub async fn find_by_shared_task_id<'e, E>(
|
||||||
executor: E,
|
executor: E,
|
||||||
shared_task_id: Uuid,
|
shared_task_id: Uuid,
|
||||||
@@ -458,21 +441,6 @@ ORDER BY t.created_at DESC"#,
|
|||||||
Ok(result.rows_affected())
|
Ok(result.rows_affected())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn exists(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
id: Uuid,
|
|
||||||
project_id: Uuid,
|
|
||||||
) -> Result<bool, sqlx::Error> {
|
|
||||||
let result = sqlx::query!(
|
|
||||||
"SELECT id as \"id!: Uuid\" FROM tasks WHERE id = $1 AND project_id = $2",
|
|
||||||
id,
|
|
||||||
project_id
|
|
||||||
)
|
|
||||||
.fetch_optional(pool)
|
|
||||||
.await?;
|
|
||||||
Ok(result.is_some())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn find_children_by_attempt_id(
|
pub async fn find_children_by_attempt_id(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
attempt_id: Uuid,
|
attempt_id: Uuid,
|
||||||
|
|||||||
@@ -262,30 +262,6 @@ impl TaskAttempt {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find task attempts by task_id with project git repo path for cleanup operations
|
|
||||||
pub async fn find_by_task_id_with_project(
|
|
||||||
pool: &SqlitePool,
|
|
||||||
task_id: Uuid,
|
|
||||||
) -> Result<Vec<(Uuid, Option<String>, String)>, sqlx::Error> {
|
|
||||||
let records = sqlx::query!(
|
|
||||||
r#"
|
|
||||||
SELECT ta.id as "attempt_id!: Uuid", ta.container_ref, p.git_repo_path as "git_repo_path!"
|
|
||||||
FROM task_attempts ta
|
|
||||||
JOIN tasks t ON ta.task_id = t.id
|
|
||||||
JOIN projects p ON t.project_id = p.id
|
|
||||||
WHERE ta.task_id = $1
|
|
||||||
"#,
|
|
||||||
task_id
|
|
||||||
)
|
|
||||||
.fetch_all(pool)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(records
|
|
||||||
.into_iter()
|
|
||||||
.map(|r| (r.attempt_id, r.container_ref, r.git_repo_path))
|
|
||||||
.collect())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn find_by_worktree_deleted(
|
pub async fn find_by_worktree_deleted(
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
) -> Result<Vec<(Uuid, String)>, sqlx::Error> {
|
) -> Result<Vec<(Uuid, String)>, sqlx::Error> {
|
||||||
|
|||||||
Reference in New Issue
Block a user