fix: 单个检查也刷新本月学时
This commit is contained in:
@@ -129,7 +129,7 @@ def _checked_profile(client) -> dict:
|
||||
return payload
|
||||
|
||||
|
||||
def check_employee(db: Session, employee_id: str, *, refresh_hours: bool = False) -> dict:
|
||||
def check_employee(db: Session, employee_id: str) -> dict:
|
||||
from euniv.proxy import bind_url, is_proxy_failure, url_of, uses_pool
|
||||
from euniv.proxy_pool import MAX_SWITCHES, retire_if_dead
|
||||
|
||||
@@ -155,7 +155,7 @@ def check_employee(db: Session, employee_id: str, *, refresh_hours: bool = False
|
||||
result = "有效" if alive else "已失效"
|
||||
valid = alive
|
||||
profile = _checked_profile(client) if alive else {}
|
||||
if alive and refresh_hours:
|
||||
if alive:
|
||||
hours = _checked_hours(client)
|
||||
break
|
||||
except Exception as exc:
|
||||
@@ -200,7 +200,7 @@ def _check_saved(db: Session, employee_ids: list[str]) -> list[dict]:
|
||||
results = []
|
||||
for employee_id in employee_ids:
|
||||
try:
|
||||
results.append(check_employee(db, employee_id, refresh_hours=True))
|
||||
results.append(check_employee(db, employee_id))
|
||||
except HTTPException as exc:
|
||||
if exc.status_code == 404:
|
||||
continue
|
||||
@@ -232,7 +232,7 @@ def _run_check(employee_ids: list[str]) -> None:
|
||||
for employee_id in employee_ids:
|
||||
with SessionLocal() as db:
|
||||
try:
|
||||
results.append(check_employee(db, employee_id, refresh_hours=True))
|
||||
results.append(check_employee(db, employee_id))
|
||||
except HTTPException as exc:
|
||||
if exc.status_code != 404:
|
||||
raise
|
||||
|
||||
@@ -528,7 +528,10 @@ def test_check_skips_empty_credential_and_updates_saved_one(monkeypatch) -> None
|
||||
assert saved["has_credential"] is True
|
||||
assert saved["refresh_paused"] is False
|
||||
assert saved["credential_valid"] is True
|
||||
assert saved["month_hours"] == ""
|
||||
from euniv.study_window import month_key
|
||||
|
||||
assert saved["month_hours"] == "660"
|
||||
assert saved["hours_month"] == month_key()
|
||||
assert saved["user_name"] == "莫英达"
|
||||
assert saved["company"] == "广州瀚信广州处"
|
||||
assert isinstance(saved["last_refresh_at"], str)
|
||||
|
||||
Reference in New Issue
Block a user