fix(20): add SNMP profiles settings link and device_count to profile list
Adds SNMP Device Profiles card to SettingsPage for discoverability. Adds device_count correlated subquery to profile list SQL and schema field so the frontend profile cards show accurate device counts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,11 +79,17 @@ async def list_profiles(
|
||||
|
||||
result = await db.execute(
|
||||
text("""
|
||||
SELECT id, tenant_id, name, description, sys_object_id, vendor,
|
||||
category, is_system, created_at, updated_at
|
||||
FROM snmp_profiles
|
||||
WHERE tenant_id = :tenant_id OR tenant_id IS NULL
|
||||
ORDER BY is_system DESC, name ASC
|
||||
SELECT sp.id, sp.tenant_id, sp.name, sp.description, sp.sys_object_id, sp.vendor,
|
||||
sp.category, sp.is_system, sp.created_at, sp.updated_at,
|
||||
COALESCE(dc.device_count, 0) AS device_count
|
||||
FROM snmp_profiles sp
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT COUNT(*) AS device_count
|
||||
FROM devices d
|
||||
WHERE d.snmp_profile_id = sp.id
|
||||
) dc ON true
|
||||
WHERE sp.tenant_id = :tenant_id OR sp.tenant_id IS NULL
|
||||
ORDER BY sp.is_system DESC, sp.name ASC
|
||||
"""),
|
||||
{"tenant_id": str(tenant_id)},
|
||||
)
|
||||
|
||||
@@ -75,6 +75,7 @@ class SNMPProfileResponse(BaseModel):
|
||||
vendor: Optional[str] = None
|
||||
category: Optional[str] = None
|
||||
is_system: bool
|
||||
device_count: int = 0
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
Reference in New Issue
Block a user