diff --git a/app/db/migrations.py b/app/db/migrations.py index 4b49928..5ea35d0 100644 --- a/app/db/migrations.py +++ b/app/db/migrations.py @@ -41,11 +41,11 @@ def run_migrations(): con.execute( """ CREATE TABLE IF NOT EXISTS workers ( - worker_id TEXT PRIMARY KEY, - status TEXT, - last_seen_at TEXT, + id TEXT PRIMARY KEY, + status TEXT NOT NULL DEFAULT 'online', + started_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, + last_seen_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, current_job_id INTEGER, - started_at TEXT, metadata_json TEXT ) """ diff --git a/app/db/workers.py b/app/db/workers.py index 4c446e2..9987d5b 100644 --- a/app/db/workers.py +++ b/app/db/workers.py @@ -51,14 +51,14 @@ def get_workers(): rows = con.execute( """ SELECT - worker_id, + id, status, + started_at, last_seen_at, current_job_id, - started_at, metadata_json FROM workers - ORDER BY worker_id + ORDER BY id """ ).fetchall() @@ -73,14 +73,14 @@ def get_worker(worker_id: str): row = con.execute( """ SELECT - worker_id, + id, status, + started_at, last_seen_at, current_job_id, - started_at, metadata_json FROM workers - WHERE worker_id = ? + WHERE id = ? """, (worker_id,), ).fetchone() diff --git a/app/routes/workers.py b/app/routes/workers.py index c2db0d5..2f68293 100644 --- a/app/routes/workers.py +++ b/app/routes/workers.py @@ -49,7 +49,7 @@ def workers_page(request: Request, user=Depends(require_user)): rows = "" for worker in workers: - worker_id_raw = worker.get("worker_id", "") or "" + worker_id_raw = worker.get("id", "") or "" worker_id = html.escape(worker_id_raw) worker_url_id = quote(worker_id_raw, safe="") status = html.escape(worker.get("status", "") or "") @@ -124,7 +124,7 @@ def worker_detail_page(worker_id: str, request: Request, user=Depends(require_us target_id=worker_id, ) - worker_id_html = html.escape(worker.get("worker_id", "") or "") + worker_id_html = html.escape(worker.get("id", "") or "") status = html.escape(worker.get("status", "") or "") last_seen_at = html.escape(worker.get("last_seen_at", "") or "") started_at = html.escape(worker.get("started_at", "") or "")