fix: correct PostgreSQL device row mapping

This commit is contained in:
Thomas Stallinger 2026-07-12 15:32:43 +02:00
parent 2683b65ffc
commit ba2dccff57

11
app.py
View File

@ -75,7 +75,7 @@ def load_or_create_device(
if str(row[1]) != str(organization_id): if str(row[1]) != str(organization_id):
raise RuntimeError( raise RuntimeError(
"Das Gerät ist bereits einer anderen Organization zugeordnet." "Das Gerät ist bereits einer anderen Organization zugeordnet."
) )
cur.execute( cur.execute(
""" """
UPDATE devices UPDATE devices
@ -110,6 +110,7 @@ def load_or_create_device(
VALUES (%s, %s, %s, %s) VALUES (%s, %s, %s, %s)
RETURNING RETURNING
id, id,
organization_id,
device_fingerprint, device_fingerprint,
hostname, hostname,
created_at, created_at,
@ -129,10 +130,10 @@ def load_or_create_device(
device = { device = {
"id": str(row[0]), "id": str(row[0]),
"organization_id": str(row[1]), "organization_id": str(row[1]),
"device_fingerprint": row[1], "device_fingerprint": row[2],
"hostname": row[2], "hostname": row[3],
"created_at": row[3].isoformat(), "created_at": row[4].isoformat(),
"last_seen": row[4].isoformat(), "last_seen": row[5].isoformat(),
} }
return device, created return device, created