Files
gitea a16050c80a
CI / lint-and-build (push) Has been cancelled
CI / python-checks (3.12) (push) Has been cancelled
feat: multiple updates - alerts, auth, sectors, rotation service, financials ingestion, task specs, and agent framework
2026-06-06 22:01:40 -04:00

47 lines
1.8 KiB
Markdown

# Task: Migrate POST/PUT/DELETE endpoints to AlertService
## Goal
Replace `routers/alerts.py` write endpoints (`create_alert`, `update_alert`, `resolve_alert`, `dismiss_alert`) to use `AlertService`.
## Requirements
### Changes to `src/backend/routers/alerts.py`
1. Replace `create_alert()` body:
- Call `service.create_alert(watchlist_id, type, trigger_type, message, severity, ticker, metadata, user_id)`
- Return `AlertResponse` wrapping the result
- Keep the watchlist owner check
2. Replace `update_alert()` body:
- Use `service.get_alert()` to verify existence and ownership
- Build updates dict from `body` fields
- Call `service.update_alert(alert_id, updates_dict, user_id)`
- Return `AlertResponse` wrapping the result
3. Replace `resolve_alert()` body:
- Use `service.get_alert()` to verify existence and ownership
- Call `service.resolve_alert(alert_id, user_id)`
- Return `AlertResponse` wrapping the result
4. Replace `dismiss_alert()` body:
- Use `service.get_alert()` to verify existence and ownership
- Call `service.dismiss_alert(alert_id, user_id)`
- Return `None` (204 response)
### Constraints
- Keep all route signatures, decorators, and response models unchanged
- Keep `check_all_alerts` endpoint unchanged (it calls `check_sentiment_alerts` directly)
- File must stay under 200 lines total
## Acceptance Criteria
1. All write endpoints use `AlertService` methods
2. All alert CRUD tests pass: `pytest tests/test_alerts.py -k "test_create or test_update or test_delete or test_resolve or test_dismiss" --tb=short`
3. No import errors
## Files to Modify
- `src/backend/routers/alerts.py`
## Files to Read First
- `src/backend/services/alert_service.py`
- `src/backend/routers/alerts.py` — current write endpoint implementations