refactor: separate config service from jail config service
- Split config_service.py into config_service.py and jail_config_service.py - Update Docs/Tasks.md, Security.md, TROUBLESHOOTING.md
This commit is contained in:
@@ -1,52 +1,3 @@
|
||||
### Issue #15: MEDIUM - N+1 Query Pattern in Geo Lookups
|
||||
|
||||
**Where found**:
|
||||
- `backend/app/services/ban_service.py` (lines 650-680)
|
||||
- `_enrich_bans_with_geo()` calls resolver per IP in loop
|
||||
- 1000 bans = 1000 geo lookups
|
||||
|
||||
**Why this is needed**:
|
||||
Dashboard becomes slow with many bans:
|
||||
- Each geo lookup hits database or HTTP API
|
||||
- 1000 bans = 1000 lookups = seconds of latency
|
||||
- API rate limiting exceeded if fallback HTTP enabled
|
||||
|
||||
**Goal**:
|
||||
Batch geo lookups and implement caching to reduce database round-trips.
|
||||
|
||||
**What to do**:
|
||||
1. Implement batch geo resolution:
|
||||
```python
|
||||
async def enrich_bans_with_geo(bans):
|
||||
# Extract unique IPs
|
||||
unique_ips = set(ban.ip for ban in bans)
|
||||
|
||||
# Batch lookup
|
||||
geo_data = await self.geo_cache.resolve_batch(unique_ips)
|
||||
|
||||
# Attach to bans
|
||||
for ban in bans:
|
||||
ban.country = geo_data.get(ban.ip)
|
||||
```
|
||||
2. Use geo_cache for persistence (cache is already designed for batching)
|
||||
3. Add metrics for cache hit/miss ratio
|
||||
4. Implement pre-warming of common IPs
|
||||
5. Add tests with large ban lists
|
||||
|
||||
**Possible traps and issues**:
|
||||
- Batch lookup might be slower than individual if dataset is small
|
||||
- Cache invalidation on country name updates
|
||||
- Memory usage if caching all IPs
|
||||
|
||||
**Docs changes needed**:
|
||||
- Add performance optimization guide
|
||||
- Document geo cache architecture
|
||||
|
||||
**Doc references**:
|
||||
- DETAILED_FINDINGS.md - Issue #7 "N+1 Query Pattern"
|
||||
|
||||
---
|
||||
|
||||
### Issue #16: MEDIUM - Silent Failures in Error Handling (Broad Exception Handlers)
|
||||
|
||||
**Where found**:
|
||||
|
||||
Reference in New Issue
Block a user