fix: 用户列表返回学时月份和真实任务状态
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user