fix: remove dead code warnings in agent defaults

This commit is contained in:
thibaud-leclere 2026-04-14 16:10:50 +02:00
parent 3cdd880344
commit dd9708bd6e

View file

@ -1,4 +1,4 @@
use rusqlite::{params, Connection, OptionalExtension, Result}; use rusqlite::{params, Connection, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use uuid::Uuid; use uuid::Uuid;
@ -142,12 +142,17 @@ impl Agent {
} }
pub fn get_default_by_role(conn: &Connection, role: AgentRole) -> Result<Agent> { pub fn get_default_by_role(conn: &Connection, role: AgentRole) -> Result<Agent> {
let default_id = match role {
AgentRole::Analyst => DEFAULT_ANALYST_AGENT_ID,
AgentRole::Developer => DEFAULT_DEVELOPER_AGENT_ID,
};
conn.query_row( conn.query_row(
"SELECT id, name, role, tool, custom_prompt, is_default, created_at, updated_at "SELECT id, name, role, tool, custom_prompt, is_default, created_at, updated_at
FROM agents FROM agents
WHERE role = ?1 AND is_default = 1 WHERE id = ?1 AND role = ?2 AND is_default = 1
LIMIT 1", LIMIT 1",
params![role.as_str()], params![default_id, role.as_str()],
from_row, from_row,
) )
} }
@ -198,14 +203,7 @@ impl Agent {
)); ));
} }
let default_agent_id: String = conn let default_agent = Self::get_default_by_role(conn, agent.role.clone()).map_err(|_| {
.query_row(
"SELECT id FROM agents WHERE role = ?1 AND is_default = 1 LIMIT 1",
params![agent.role.as_str()],
|row| row.get(0),
)
.optional()?
.ok_or_else(|| {
rusqlite::Error::InvalidParameterName(format!( rusqlite::Error::InvalidParameterName(format!(
"No default agent found for role '{}'", "No default agent found for role '{}'",
agent.role.as_str() agent.role.as_str()
@ -216,13 +214,13 @@ impl Agent {
AgentRole::Analyst => { AgentRole::Analyst => {
conn.execute( conn.execute(
"UPDATE watched_trackers SET analyst_agent_id = ?1 WHERE analyst_agent_id = ?2", "UPDATE watched_trackers SET analyst_agent_id = ?1 WHERE analyst_agent_id = ?2",
params![default_agent_id, id], params![default_agent.id, id],
)?; )?;
} }
AgentRole::Developer => { AgentRole::Developer => {
conn.execute( conn.execute(
"UPDATE watched_trackers SET developer_agent_id = ?1 WHERE developer_agent_id = ?2", "UPDATE watched_trackers SET developer_agent_id = ?1 WHERE developer_agent_id = ?2",
params![default_agent_id, id], params![default_agent.id, id],
)?; )?;
} }
} }