mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
Refactor API routes and enhance recipe and filter management
- Removed the handle_get_recipes method from ApiRoutes to streamline the API structure. - Updated RecipeRoutes to include logging for recipe retrieval requests and improved filter management. - Consolidated filter management logic in FilterManager to support both recipes and loras, enhancing code reusability. - Deleted obsolete LoraSearchManager and RecipeSearchManager classes to simplify the search functionality. - Improved infinite scroll implementation for both recipes and loras, ensuring consistent loading behavior across pages.
This commit is contained in:
@@ -50,7 +50,6 @@ class ApiRoutes:
|
||||
app.router.add_get('/api/lora-preview-url', routes.get_lora_preview_url) # Add new route
|
||||
app.router.add_post('/api/move_models_bulk', routes.move_models_bulk)
|
||||
app.router.add_get('/api/top-tags', routes.get_top_tags) # Add new route for top tags
|
||||
app.router.add_get('/api/recipes', cls.handle_get_recipes)
|
||||
|
||||
# Add update check routes
|
||||
UpdateRoutes.setup_routes(app)
|
||||
@@ -842,30 +841,4 @@ class ApiRoutes:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'error': 'Internal server error'
|
||||
}, status=500)
|
||||
|
||||
@staticmethod
|
||||
async def handle_get_recipes(request):
|
||||
"""API endpoint for getting paginated recipes"""
|
||||
try:
|
||||
# Get query parameters with defaults
|
||||
page = int(request.query.get('page', '1'))
|
||||
page_size = int(request.query.get('page_size', '20'))
|
||||
sort_by = request.query.get('sort_by', 'date')
|
||||
search = request.query.get('search', None)
|
||||
|
||||
# Get scanner instance
|
||||
scanner = RecipeScanner(LoraScanner())
|
||||
|
||||
# Get paginated data
|
||||
result = await scanner.get_paginated_data(
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
sort_by=sort_by,
|
||||
search=search
|
||||
)
|
||||
|
||||
return web.json_response(result)
|
||||
except Exception as e:
|
||||
logger.error(f"Error retrieving recipes: {e}", exc_info=True)
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
}, status=500)
|
||||
Reference in New Issue
Block a user