generated from Grigo/AndroidTemplate
fix
This commit is contained in:
@@ -149,6 +149,25 @@ def _trim_telemetry(conn: sqlite3.Connection, device_id: str) -> None:
|
||||
)
|
||||
|
||||
|
||||
def update_device_label(device_id: str, label: str) -> dict[str, Any]:
|
||||
if not is_valid_device_id(device_id):
|
||||
raise ValueError(f"invalid device_id '{device_id}'")
|
||||
clean = (label or "").strip()
|
||||
if not clean:
|
||||
raise ValueError("label required")
|
||||
ts = time.time()
|
||||
with _db() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO devices (device_id, label, last_seen)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(device_id) DO UPDATE SET label = excluded.label
|
||||
""",
|
||||
(device_id, clean, ts),
|
||||
)
|
||||
return {"ok": True, "device_id": device_id, "label": clean}
|
||||
|
||||
|
||||
def list_devices() -> list[dict[str, Any]]:
|
||||
with _db() as conn:
|
||||
rows = conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user