fix: 用户列表返回学时月份和真实任务状态

This commit is contained in:
2026-11-16 03:18:08 +08:00
parent 2fb40c37ae
commit f42633b5ad
2 changed files with 12 additions and 0 deletions
+9
View File
@@ -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
+3
View File
@@ -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