Fix list_recipes to use offset parameter
Match the router's expected signature and return type. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ class RecipeService:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def list_recipes(self, actor_id: str = None, page: int = 1, limit: int = 20) -> Dict[str, Any]:
|
async def list_recipes(self, actor_id: str = None, offset: int = 0, limit: int = 20) -> list:
|
||||||
"""List available recipes with pagination."""
|
"""List available recipes with pagination."""
|
||||||
recipes = []
|
recipes = []
|
||||||
cursor = 0
|
cursor = 0
|
||||||
@@ -59,20 +59,7 @@ class RecipeService:
|
|||||||
recipes.sort(key=lambda r: r.get("name", ""))
|
recipes.sort(key=lambda r: r.get("name", ""))
|
||||||
|
|
||||||
# Paginate
|
# Paginate
|
||||||
total = len(recipes)
|
return recipes[offset:offset + limit]
|
||||||
start = (page - 1) * limit
|
|
||||||
end = start + limit
|
|
||||||
page_recipes = recipes[start:end]
|
|
||||||
|
|
||||||
return {
|
|
||||||
"recipes": page_recipes,
|
|
||||||
"pagination": {
|
|
||||||
"page": page,
|
|
||||||
"limit": limit,
|
|
||||||
"total": total,
|
|
||||||
"has_more": end < total,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async def save_recipe(self, recipe_id: str, recipe_data: Dict[str, Any]) -> None:
|
async def save_recipe(self, recipe_id: str, recipe_data: Dict[str, Any]) -> None:
|
||||||
"""Save a recipe to Redis."""
|
"""Save a recipe to Redis."""
|
||||||
|
|||||||
Reference in New Issue
Block a user