←
APC-10
Created: 2025-12-22
•
Updated: 2025-12-22
Relationships
Loading...
Attachments
Loading...
Comments (1)
agent
·
2025-12-22
## Implementation Complete
### Changes Made
1. **New /api/power/history endpoint** (app/api/power_router.py:104-212)
- Implements GET /api/power/history with all required query parameters:
- range: 1h|24h|7d|30d (default: 24h)
- resolution: 1m|5m|1h (default: 1m for raw data)
- outlet_id: Filter by specific outlet (1-24)
- device_id: Filter by device (returns all outlets assigned to device)
- include_outlets: Include individual outlet readings
- Returns time-series data with aggregations (avg, min, max) in statistics
2. **Resolution/Aggregation** (app/api/power_router.py:43-91)
- 1m = raw data (no aggregation)
- 5m = 5-minute bucket averages
- 1h = hourly bucket averages
3. **Data Retention/Cleanup** (app/services/metrics_collector.py:164-199)
- Added DATA_RETENTION_DAYS config setting (default: 30 days)
- Cleanup runs automatically every ~1 hour
- Set to 0 to disable cleanup
### Test Results
All 220 tests pass, including 23 new tests for the power history API and 4 new tests for data retention cleanup.