Add latest changes
Dieser Commit ist enthalten in:
56
v2_adminpanel/test_device_count.py
Normale Datei
56
v2_adminpanel/test_device_count.py
Normale Datei
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test script to verify device count is properly returned from API"""
|
||||
|
||||
import sys
|
||||
sys.path.append('/opt/v2-Docker/v2_adminpanel')
|
||||
|
||||
from db import get_connection
|
||||
|
||||
def test_device_count():
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
try:
|
||||
# Get the license we're interested in
|
||||
license_key = 'AF-F-202506-WY2J-ZZB9-7LZD'
|
||||
|
||||
# Get license ID
|
||||
cur.execute("SELECT id FROM licenses WHERE license_key = %s", (license_key,))
|
||||
result = cur.fetchone()
|
||||
if not result:
|
||||
print(f"License {license_key} not found")
|
||||
return
|
||||
|
||||
license_id = result[0]
|
||||
print(f"License ID: {license_id}")
|
||||
|
||||
# Count active devices from activations table
|
||||
cur.execute("""
|
||||
SELECT COUNT(*) FROM activations
|
||||
WHERE license_id = %s AND is_active = true
|
||||
""", (license_id,))
|
||||
active_device_count = cur.fetchone()[0]
|
||||
|
||||
print(f"Active devices count: {active_device_count}")
|
||||
|
||||
# Show all activations for this license
|
||||
cur.execute("""
|
||||
SELECT machine_id, device_name, is_active, first_seen, last_seen
|
||||
FROM activations
|
||||
WHERE license_id = %s
|
||||
ORDER BY first_seen DESC
|
||||
""", (license_id,))
|
||||
|
||||
print("\nAll activations for this license:")
|
||||
for row in cur.fetchall():
|
||||
status = "ACTIVE" if row[2] else "INACTIVE"
|
||||
print(f" - {row[1]} ({row[0][:12]}...) - {status} - First: {row[3]} - Last: {row[4]}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
finally:
|
||||
cur.close()
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_device_count()
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren