From 9a8e26e79c0ddce7e061901223e34cef2b4a8316 Mon Sep 17 00:00:00 2001 From: gilesb Date: Sun, 11 Jan 2026 22:09:34 +0000 Subject: [PATCH] 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 --- app/services/recipe_service.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/services/recipe_service.py b/app/services/recipe_service.py index a81306b..760283e 100644 --- a/app/services/recipe_service.py +++ b/app/services/recipe_service.py @@ -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: