Ressourcen bei Kunden&Lizenzen ist richtig

Dieser Commit ist enthalten in:
2025-06-15 21:39:20 +02:00
Ursprung a878d9b29c
Commit df60ce6d18
2 geänderte Dateien mit 67 neuen und 49 gelöschten Zeilen

Datei anzeigen

@@ -2351,7 +2351,17 @@ def customers_licenses():
l.ipv4_count,
l.phone_count,
l.device_limit,
(SELECT COUNT(*) FROM device_registrations WHERE license_id = l.id AND is_active = TRUE) as active_devices
(SELECT COUNT(*) FROM device_registrations WHERE license_id = l.id AND is_active = TRUE) as active_devices,
-- Actual resource counts
(SELECT COUNT(*) FROM license_resources lr
JOIN resource_pools rp ON lr.resource_id = rp.id
WHERE lr.license_id = l.id AND lr.is_active = true AND rp.resource_type = 'domain') as actual_domain_count,
(SELECT COUNT(*) FROM license_resources lr
JOIN resource_pools rp ON lr.resource_id = rp.id
WHERE lr.license_id = l.id AND lr.is_active = true AND rp.resource_type = 'ipv4') as actual_ipv4_count,
(SELECT COUNT(*) FROM license_resources lr
JOIN resource_pools rp ON lr.resource_id = rp.id
WHERE lr.license_id = l.id AND lr.is_active = true AND rp.resource_type = 'phone') as actual_phone_count
FROM licenses l
WHERE l.customer_id = %s
ORDER BY l.created_at DESC, l.id DESC
@@ -2394,7 +2404,17 @@ def api_customer_licenses(customer_id):
l.ipv4_count,
l.phone_count,
l.device_limit,
(SELECT COUNT(*) FROM device_registrations WHERE license_id = l.id AND is_active = TRUE) as active_devices
(SELECT COUNT(*) FROM device_registrations WHERE license_id = l.id AND is_active = TRUE) as active_devices,
-- Actual resource counts
(SELECT COUNT(*) FROM license_resources lr
JOIN resource_pools rp ON lr.resource_id = rp.id
WHERE lr.license_id = l.id AND lr.is_active = true AND rp.resource_type = 'domain') as actual_domain_count,
(SELECT COUNT(*) FROM license_resources lr
JOIN resource_pools rp ON lr.resource_id = rp.id
WHERE lr.license_id = l.id AND lr.is_active = true AND rp.resource_type = 'ipv4') as actual_ipv4_count,
(SELECT COUNT(*) FROM license_resources lr
JOIN resource_pools rp ON lr.resource_id = rp.id
WHERE lr.license_id = l.id AND lr.is_active = true AND rp.resource_type = 'phone') as actual_phone_count
FROM licenses l
WHERE l.customer_id = %s
ORDER BY l.created_at DESC, l.id DESC
@@ -2441,11 +2461,14 @@ def api_customer_licenses(customer_id):
'valid_until': row[4].strftime('%d.%m.%Y') if row[4] else '',
'is_active': row[5],
'status': row[6],
'domain_count': row[7],
'ipv4_count': row[8],
'phone_count': row[9],
'domain_count': row[7], # limit
'ipv4_count': row[8], # limit
'phone_count': row[9], # limit
'device_limit': row[10],
'active_devices': row[11],
'actual_domain_count': row[12], # actual count
'actual_ipv4_count': row[13], # actual count
'actual_phone_count': row[14], # actual count
'resources': resources
})