diff options
Diffstat (limited to 'makima/src/server')
| -rw-r--r-- | makima/src/server/handlers/directives.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/makima/src/server/handlers/directives.rs b/makima/src/server/handlers/directives.rs index 560151b..a877c6b 100644 --- a/makima/src/server/handlers/directives.rs +++ b/makima/src/server/handlers/directives.rs @@ -9,7 +9,7 @@ use axum::{ use uuid::Uuid; use crate::db::models::{ - ChainWithSteps, CreateDirectiveRequest, Directive, DirectiveChain, + ChainStep, ChainWithSteps, CreateDirectiveRequest, Directive, DirectiveChain, DirectiveListResponse, DirectiveWithChains, UpdateDirectiveRequest, }; use crate::db::repository::{self, RepositoryError}; @@ -122,7 +122,24 @@ pub async fn get_directive( } }; - Json(DirectiveWithChains { directive, chains }).into_response() + // Build chains with steps + let mut chains_with_steps = Vec::new(); + for chain in chains { + let steps = match repository::list_steps_for_chain(pool, chain.id).await { + Ok(s) => s, + Err(e) => { + tracing::warn!("Failed to get steps for chain {}: {}", chain.id, e); + Vec::new() + } + }; + chains_with_steps.push(ChainWithSteps { chain, steps }); + } + + Json(DirectiveWithChains { + directive, + chains: chains_with_steps, + }) + .into_response() } /// Create a new directive. |
