From 3ebe9d159a182e5e491ef929514be0848b1980b1 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Fri, 21 Mar 2025 20:00:15 +0800 Subject: [PATCH] Refactor LoraRoutes to return empty recipes when no data is available - Removed the logic for fetching and formatting recipes from the cache. - Updated the response to return an empty list for recipes when no data is present, simplifying the flow. - Adjusted comments for clarity regarding the new behavior. --- py/routes/lora_routes.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/py/routes/lora_routes.py b/py/routes/lora_routes.py index ae1a5d8f..d61f3500 100644 --- a/py/routes/lora_routes.py +++ b/py/routes/lora_routes.py @@ -116,25 +116,8 @@ class LoraRoutes: request=request # Pass the request object to the template ) else: - # Normal flow - get recipes with the same formatting as the API endpoint - cache = await self.recipe_scanner.get_cached_data() - recipes_data = cache.sorted_by_name[:20] # Show first 20 recipes by name - - # Format the response data with static URLs for file paths - same as in recipe_routes - for item in recipes_data: - # Always ensure file_url is set - if 'file_path' in item: - item['file_url'] = self._format_recipe_file_url(item['file_path']) - else: - item['file_url'] = '/loras_static/images/no-preview.png' - - # Ensure loras array exists - if 'loras' not in item: - item['loras'] = [] - - # Ensure base_model field exists - if 'base_model' not in item: - item['base_model'] = "" + # return empty recipes + recipes_data = [] template = self.template_env.get_template('recipes.html') rendered = template.render(