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