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:
@@ -368,13 +368,15 @@ pub async fn create_topic(
|
|||||||
|
|
||||||
let id = cm_db::repo::research_topics::create(
|
let id = cm_db::repo::research_topics::create(
|
||||||
&state.pool,
|
&state.pool,
|
||||||
user.workspace_id.as_uuid(),
|
cm_db::repo::research_topics::NewTopic {
|
||||||
body.title.trim(),
|
workspace_id: user.workspace_id.as_uuid(),
|
||||||
body.description.trim(),
|
title: body.title.trim(),
|
||||||
&body.outcome_kind,
|
description: body.description.trim(),
|
||||||
|
outcome_kind: &body.outcome_kind,
|
||||||
topology_kind,
|
topology_kind,
|
||||||
repo_id,
|
repo_id,
|
||||||
user.user_id.as_uuid(),
|
created_by: user.user_id.as_uuid(),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -275,13 +275,15 @@ async fn notify_run_completed_transitions_topic_when_no_siblings_in_flight() {
|
|||||||
|
|
||||||
let topic = research_topics::create(
|
let topic = research_topics::create(
|
||||||
&pool,
|
&pool,
|
||||||
ws.as_uuid(),
|
research_topics::NewTopic {
|
||||||
"Topic",
|
workspace_id: ws.as_uuid(),
|
||||||
"desc",
|
title: "Topic",
|
||||||
"spec",
|
description: "desc",
|
||||||
"hub_spoke",
|
outcome_kind: "spec",
|
||||||
None,
|
topology_kind: "hub_spoke",
|
||||||
user_id.as_uuid(),
|
repo_id: None,
|
||||||
|
created_by: user_id.as_uuid(),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -326,13 +328,15 @@ async fn notify_run_completed_leaves_topic_processing_when_siblings_in_flight()
|
|||||||
|
|
||||||
let topic = research_topics::create(
|
let topic = research_topics::create(
|
||||||
&pool,
|
&pool,
|
||||||
ws.as_uuid(),
|
research_topics::NewTopic {
|
||||||
"Topic",
|
workspace_id: ws.as_uuid(),
|
||||||
"desc",
|
title: "Topic",
|
||||||
"spec",
|
description: "desc",
|
||||||
"hub_spoke",
|
outcome_kind: "spec",
|
||||||
None,
|
topology_kind: "hub_spoke",
|
||||||
user_id.as_uuid(),
|
repo_id: None,
|
||||||
|
created_by: user_id.as_uuid(),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
@@ -44,30 +44,35 @@ pub struct AgentSlot {
|
|||||||
pub role_slot: Option<String>,
|
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.
|
/// Creates a topic in `standby`. Returns the new row's id.
|
||||||
pub async fn create(
|
pub async fn create(pool: &PgPool, input: NewTopic<'_>) -> Result<Uuid, DbError> {
|
||||||
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> {
|
|
||||||
let id = Uuid::now_v7();
|
let id = Uuid::now_v7();
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO research_topics
|
"INSERT INTO research_topics
|
||||||
(id, workspace_id, title, description, outcome_kind, topology_kind, repo_id, status, created_by)
|
(id, workspace_id, title, description, outcome_kind, topology_kind, repo_id, status, created_by)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, 'standby', $8)",
|
VALUES ($1, $2, $3, $4, $5, $6, $7, 'standby', $8)",
|
||||||
id,
|
id,
|
||||||
workspace_id,
|
input.workspace_id,
|
||||||
title,
|
input.title,
|
||||||
description,
|
input.description,
|
||||||
outcome_kind,
|
input.outcome_kind,
|
||||||
topology_kind,
|
input.topology_kind,
|
||||||
repo_id,
|
input.repo_id,
|
||||||
created_by,
|
input.created_by,
|
||||||
)
|
)
|
||||||
.execute(pool)
|
.execute(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user