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