Compute step_count in recipe service
Check multiple locations for nodes (nodes, dag.nodes, pipeline, steps) and compute step_count for display in recipe list. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,23 @@ class RecipeService:
|
||||
if ipfs_cid:
|
||||
recipe_data["ipfs_cid"] = ipfs_cid
|
||||
|
||||
# Compute step_count from nodes
|
||||
nodes = recipe_data.get("nodes", [])
|
||||
if not nodes:
|
||||
dag = recipe_data.get("dag", {})
|
||||
nodes = dag.get("nodes", []) if isinstance(dag, dict) else []
|
||||
if not nodes:
|
||||
nodes = recipe_data.get("pipeline", [])
|
||||
if not nodes:
|
||||
nodes = recipe_data.get("steps", [])
|
||||
|
||||
if isinstance(nodes, list):
|
||||
recipe_data["step_count"] = len(nodes)
|
||||
elif isinstance(nodes, dict):
|
||||
recipe_data["step_count"] = len(nodes)
|
||||
else:
|
||||
recipe_data["step_count"] = 0
|
||||
|
||||
return recipe_data
|
||||
|
||||
async def list_recipes(self, actor_id: str = None, offset: int = 0, limit: int = 20) -> list:
|
||||
|
||||
Reference in New Issue
Block a user