1.4 KiB
1.4 KiB
Task: Cleanup alert router — remove DB calls, consolidate
Goal
Remove all remaining direct database calls from routers/alerts.py. The router should now be a thin HTTP layer only.
Requirements
Changes to src/backend/routers/alerts.py
- Remove direct imports of
execute_query,execute_command,execute_onefromdatabase - Remove the
_require_watchlist_owner()helper function (moved to AlertService) - Ensure all endpoints use
AlertServiceexclusively - The router should only contain:
- Route decorators and signatures
- Auth extraction (
current_user["id"]) - Service method calls
- Response model wrapping
- The file should be ~60-80 lines (down from ~200+)
Service layer additions if needed
If AlertService is missing a helper method the router needs, add it:
build_watchlist_in_clause(user_id)— returns (placeholders, params) for user's watchlists- Any other query helper needed by the listing endpoint
Acceptance Criteria
routers/alerts.pyhas no directexecute_query/execute_command/execute_onecalls- File is under 100 lines
- All alert tests still pass:
pytest tests/test_alerts.py --tb=short - No import errors
Files to Modify
src/backend/routers/alerts.pysrc/backend/services/alert_service.py(if new helpers needed)
Files to Read First
src/backend/routers/alerts.py— current statesrc/backend/services/alert_service.py— current service