research_topics::create: bag 8 args into a NewTopic struct (fixes clippy)
The prior signature took (pool, workspace_id, title, description, outcome_kind, topology_kind, repo_id, created_by) — 8 args, one over the clippy::too_many_arguments ceiling and blocking CI. Refactor to a NewTopic<'a> input struct mirroring the NewLoop / NewSubTopology pattern the codebase already uses. Wizard-side additions like a repo commit branch land as struct fields instead of cascading into every call site.
This commit is contained in:
@@ -44,30 +44,35 @@ pub struct AgentSlot {
|
||||
pub role_slot: Option<String>,
|
||||
}
|
||||
|
||||
/// Fields the wizard collected for a new research topic. Grouped into a
|
||||
/// struct so `create` stays under the 7-argument clippy ceiling and future
|
||||
/// wizard additions (repo commit-branch, etc.) don't cascade into every
|
||||
/// call site.
|
||||
pub struct NewTopic<'a> {
|
||||
pub workspace_id: Uuid,
|
||||
pub title: &'a str,
|
||||
pub description: &'a str,
|
||||
pub outcome_kind: &'a str,
|
||||
pub topology_kind: &'a str,
|
||||
pub repo_id: Option<Uuid>,
|
||||
pub created_by: Uuid,
|
||||
}
|
||||
|
||||
/// Creates a topic in `standby`. Returns the new row's id.
|
||||
pub async fn create(
|
||||
pool: &PgPool,
|
||||
workspace_id: Uuid,
|
||||
title: &str,
|
||||
description: &str,
|
||||
outcome_kind: &str,
|
||||
topology_kind: &str,
|
||||
repo_id: Option<Uuid>,
|
||||
created_by: Uuid,
|
||||
) -> Result<Uuid, DbError> {
|
||||
pub async fn create(pool: &PgPool, input: NewTopic<'_>) -> Result<Uuid, DbError> {
|
||||
let id = Uuid::now_v7();
|
||||
sqlx::query!(
|
||||
"INSERT INTO research_topics
|
||||
(id, workspace_id, title, description, outcome_kind, topology_kind, repo_id, status, created_by)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, 'standby', $8)",
|
||||
id,
|
||||
workspace_id,
|
||||
title,
|
||||
description,
|
||||
outcome_kind,
|
||||
topology_kind,
|
||||
repo_id,
|
||||
created_by,
|
||||
input.workspace_id,
|
||||
input.title,
|
||||
input.description,
|
||||
input.outcome_kind,
|
||||
input.topology_kind,
|
||||
input.repo_id,
|
||||
input.created_by,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user