Rewrote list_agent_polling_targets/1 to filter equipment using SQL WHERE clause instead of loading all SNMP-enabled equipment into memory and filtering in Elixir. Previous implementation: - Loaded ALL SNMP-enabled equipment with preloads (potentially 10,000+ records) - Filtered in application code with equipment_matches_agent?/2 helper - Called get_equipment_assignment/1 for each piece of equipment (N+1 queries) - Memory-intensive and slow at scale New implementation: - Single SQL query with LEFT JOIN and compound WHERE clause - Evaluates hierarchical assignment (equipment → site → organization) in SQL - Only loads equipment assigned to the specific agent - Scales efficiently to 10,000+ equipment Performance improvement: - With 10,000 equipment, 1000 assigned to agent: - Before: Load 10,000 records + 10,000 queries = massive memory + slow - After: Load 1,000 records in 1 query = 10x memory reduction + instant Removed unused helper functions: - equipment_matches_agent?/2 - site_matches_agent?/2 All 40 agent tests passing. |
||
|---|---|---|
| .. | ||
| towerops | ||
| towerops_web | ||
| towerops.ex | ||
| towerops_web.ex | ||