Record project continuation changes
This commit is contained in:
@@ -242,6 +242,37 @@ func (m *Module) loadAdminSummary(ctx context.Context, orgID string) (AdminSumma
|
||||
return AdminSummary{}, err
|
||||
}
|
||||
|
||||
var vpnConnectionCount int64
|
||||
var vpnActiveLeaseCount int64
|
||||
var vpnForwardingCount int64
|
||||
if err := m.db.QueryRow(ctx, `
|
||||
SELECT COUNT(*)
|
||||
FROM vpn_connections
|
||||
WHERE organization_id = $1::uuid
|
||||
AND desired_state = 'enabled'
|
||||
`, orgID).Scan(&vpnConnectionCount); err != nil {
|
||||
return AdminSummary{}, err
|
||||
}
|
||||
if err := m.db.QueryRow(ctx, `
|
||||
SELECT COUNT(*)
|
||||
FROM vpn_connection_leases l
|
||||
INNER JOIN vpn_connections vc ON vc.id = l.vpn_connection_id
|
||||
WHERE vc.organization_id = $1::uuid
|
||||
AND l.status = 'active'
|
||||
AND l.expires_at > NOW()
|
||||
`, orgID).Scan(&vpnActiveLeaseCount); err != nil {
|
||||
return AdminSummary{}, err
|
||||
}
|
||||
if err := m.db.QueryRow(ctx, `
|
||||
SELECT COUNT(*)
|
||||
FROM vpn_connection_assignment_latest_statuses s
|
||||
INNER JOIN vpn_connections vc ON vc.id = s.vpn_connection_id
|
||||
WHERE vc.organization_id = $1::uuid
|
||||
AND COALESCE((s.status_payload->>'packet_forwarding')::boolean, false)
|
||||
`, orgID).Scan(&vpnForwardingCount); err != nil {
|
||||
return AdminSummary{}, err
|
||||
}
|
||||
|
||||
auditRows, err := m.db.Query(ctx, `
|
||||
SELECT ae.id::text, ae.event_type, ae.target_type, ae.target_id, ae.payload, ae.created_at
|
||||
FROM audit_events ae
|
||||
@@ -265,6 +296,12 @@ func (m *Module) loadAdminSummary(ctx context.Context, orgID string) (AdminSumma
|
||||
if err := auditRows.Err(); err != nil {
|
||||
return AdminSummary{}, err
|
||||
}
|
||||
if services == nil {
|
||||
services = []ServiceSummary{}
|
||||
}
|
||||
if audit == nil {
|
||||
audit = []OrgAuditEvent{}
|
||||
}
|
||||
|
||||
return AdminSummary{
|
||||
OrganizationID: orgID,
|
||||
@@ -272,14 +309,34 @@ func (m *Module) loadAdminSummary(ctx context.Context, orgID string) (AdminSumma
|
||||
ActiveSessionCount: activeSessionCount,
|
||||
ServiceEndpoints: services,
|
||||
ConnectorStatus: map[string]any{
|
||||
"vpn": "not_implemented",
|
||||
"connector": "not_implemented",
|
||||
"vpn": map[string]any{
|
||||
"enabled_connections": vpnConnectionCount,
|
||||
"active_leases": vpnActiveLeaseCount,
|
||||
"packet_forwarding": vpnForwardingCount,
|
||||
"status": connectorStatus(vpnConnectionCount, vpnActiveLeaseCount, vpnForwardingCount),
|
||||
},
|
||||
"rdp": map[string]any{
|
||||
"status": "resource_catalog_ready",
|
||||
},
|
||||
},
|
||||
RecentAudit: audit,
|
||||
TopologyExposure: tenantSafeTopologyExposure(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func connectorStatus(enabledConnections, activeLeases, forwarding int64) string {
|
||||
if enabledConnections == 0 {
|
||||
return "not_configured"
|
||||
}
|
||||
if forwarding > 0 {
|
||||
return "active"
|
||||
}
|
||||
if activeLeases > 0 {
|
||||
return "gateway_blocked"
|
||||
}
|
||||
return "waiting_for_gateway"
|
||||
}
|
||||
|
||||
func tenantSafeTopologyExposure() string {
|
||||
return "tenant_safe_no_core_mesh_topology"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user