fix: 学习任务跨月会停,失败的课不再记成已学完

This commit is contained in:
2026-11-16 09:19:30 +08:00
parent 91b06cde25
commit 337d842543
6 changed files with 348 additions and 133 deletions
+2 -2
View File
@@ -409,8 +409,6 @@ def get_study_control(request: Request, db: Session = Depends(get_db)) -> dict:
raise HTTPException(status_code=401, detail="未登录")
status = autostudy_status()
live = dict((status.get("users") or {}).get(employee_id) or {})
if not live.get("message"):
live["message"] = str(status.get("message") or "")
if settle(account, live):
db.commit()
return assemble(account, live)
@@ -428,6 +426,8 @@ def post_study_control(body: StudyControlBody, request: Request, db: Session = D
raise HTTPException(status_code=401, detail="未登录")
action = (body.action or "").strip().lower()
if action == "start":
if int(account.monthly_target or 0) <= 0:
raise HTTPException(status_code=400, detail="每月目标为 0,不会学习")
if hours_met(account):
from euniv.autostudy import halt_work