feat: 管理端定时日扩到1至28号,学时顺带写回列表
This commit is contained in:
@@ -367,7 +367,9 @@ def poll_qr_login(db: Session, attempt_id: str) -> dict:
|
||||
|
||||
|
||||
def fetch_home_summary(db: Session, employee_id: str, client_factory=EunivClient) -> dict:
|
||||
return _live(db, employee_id, client_factory, lambda client: _apply_hours_source(client, client.home_summary()))
|
||||
data = _live(db, employee_id, client_factory, lambda client: _apply_hours_source(client, client.home_summary()))
|
||||
_remember_month_hours(db, employee_id, data)
|
||||
return data
|
||||
|
||||
|
||||
def fetch_home_exams(db: Session, employee_id: str, client_factory=EunivClient) -> dict:
|
||||
@@ -402,7 +404,9 @@ def fetch_study_history(db: Session, employee_id: str, client_factory=EunivClien
|
||||
hours = _hour_fields(_apply_hours_source(client, _api_hour_fields(client), items))
|
||||
return {"items": items, "total": len(items), **hours}
|
||||
|
||||
return _live(db, employee_id, client_factory, read)
|
||||
data = _live(db, employee_id, client_factory, read)
|
||||
_remember_month_hours(db, employee_id, data)
|
||||
return data
|
||||
|
||||
|
||||
def _apply_hours_source(client, summary: dict, items: list | None = None) -> dict:
|
||||
@@ -447,6 +451,25 @@ def _api_hour_fields(client) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _remember_month_hours(db: Session, employee_id: str, payload: dict) -> None:
|
||||
"""首页、学时历史这些已经取到本月学时的地方,顺手写回用户列表。"""
|
||||
if not isinstance(payload, dict):
|
||||
return
|
||||
raw = payload.get("month_hours")
|
||||
if raw is None or isinstance(raw, bool):
|
||||
return
|
||||
text = str(raw).strip()
|
||||
if not text:
|
||||
return
|
||||
account = db.get(Account, employee_id)
|
||||
if account is None:
|
||||
return
|
||||
from euniv.study_control import stamp_hours
|
||||
|
||||
stamp_hours(account, text)
|
||||
db.commit()
|
||||
|
||||
|
||||
def _hour_fields(data: dict) -> dict:
|
||||
fields = {
|
||||
"hours_source": data.get("hours_source") or "api",
|
||||
|
||||
Reference in New Issue
Block a user