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:
Gabriel Gordon-Hall
2025-12-11 16:25:00 +00:00
committed by GitHub
parent 2366e4ad23
commit 9688734e99
6 changed files with 0 additions and 272 deletions

View File

@@ -168,25 +168,6 @@ impl ExecutionProcess {
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
pub async fn find_by_rowid(pool: &SqlitePool, rowid: i64) -> Result<Option<Self>, sqlx::Error> {
sqlx::query_as!(
@@ -479,19 +460,6 @@ impl ExecutionProcess {
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> {
match &self.executor_action.0 {
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)
pub async fn drop_at_and_after(
pool: &SqlitePool,

View File

@@ -47,17 +47,6 @@ impl ExecutionProcessLogs {
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
pub async fn append_log_line(
pool: &SqlitePool,

View File

@@ -32,28 +32,6 @@ pub struct UpdateExecutorSession {
}
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
pub async fn find_by_execution_process_id(
pool: &SqlitePool,
@@ -78,57 +56,6 @@ impl ExecutorSession {
.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
pub async fn create(
pool: &SqlitePool,
@@ -194,28 +121,6 @@ impl ExecutorSession {
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
pub async fn update_summary(
pool: &SqlitePool,
@@ -236,19 +141,4 @@ impl ExecutorSession {
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(())
}
}

View File

@@ -149,32 +149,6 @@ impl Project {
.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(
pool: &SqlitePool,
git_repo_path: &str,
@@ -364,19 +338,4 @@ impl Project {
.await?;
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)
}
}

View File

@@ -238,23 +238,6 @@ ORDER BY t.created_at DESC"#,
.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>(
executor: E,
shared_task_id: Uuid,
@@ -458,21 +441,6 @@ ORDER BY t.created_at DESC"#,
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(
pool: &SqlitePool,
attempt_id: Uuid,

View File

@@ -262,30 +262,6 @@ impl TaskAttempt {
.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(
pool: &SqlitePool,
) -> Result<Vec<(Uuid, String)>, sqlx::Error> {