From f42633b5ad8aa4682c85a1aba33f242b6792261b Mon Sep 17 00:00:00 2001 From: Nixevol Date: Mon, 16 Nov 2026 03:18:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=AD=A6=E6=97=B6=E6=9C=88=E4=BB=BD=E5=92=8C?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/admin/users.py | 9 +++++++++ backend/tests/test_admin.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/backend/admin/users.py b/backend/admin/users.py index f403f83..93c46e6 100644 --- a/backend/admin/users.py +++ b/backend/admin/users.py @@ -66,10 +66,16 @@ def _iso_time(value: datetime | None) -> str | None: def list_users(db: Session) -> list[dict]: + from euniv.autostudy import autostudy_status, work_running + accounts = db.scalars(select(Account).order_by(Account.employee_id)).all() + live_users = autostudy_status().get("users") or {} rows = [] for account in accounts: control = study_view(account) + live = live_users.get(account.employee_id) if isinstance(live_users, dict) else {} + if not isinstance(live, dict): + live = {} rows.append( { "employee_id": account.employee_id, @@ -91,6 +97,9 @@ def list_users(db: Session) -> list[dict]: "study_paused": control["paused"], "study_ignore_window": control["ignore_window"], "study_started": control["started"], + "hours_month": account.hours_month or "", + "study_active": work_running(account.employee_id), + "state": str(live.get("state") or ""), } ) return rows diff --git a/backend/tests/test_admin.py b/backend/tests/test_admin.py index e6febdc..ffb21f9 100644 --- a/backend/tests/test_admin.py +++ b/backend/tests/test_admin.py @@ -503,6 +503,9 @@ def test_check_skips_empty_credential_and_updates_saved_one() -> None: "study_paused", "study_ignore_window", "study_started", + "hours_month", + "study_active", + "state", } assert saved["has_credential"] is True assert saved["refresh_paused"] is False