fix: 不让空的或上月学时盖住首页,会话失效后停止重连

This commit is contained in:
2026-11-16 02:48:38 +08:00
parent 252bfbf60b
commit 8706b8f447
3 changed files with 24 additions and 4 deletions
+5 -1
View File
@@ -129,7 +129,11 @@ def assemble(account, live: dict | None = None, now: datetime | None = None) ->
payload["active"] = running
payload["started"] = running
cached_hours = str(info.get("month_hours") or "")
payload["month_hours"] = cached_hours or str(getattr(account, "month_hours", "") or "")
stored_hours = str(getattr(account, "month_hours", "") or "")
recorded_month = str(getattr(account, "hours_month", "") or "")
if recorded_month and recorded_month != month_key(now):
stored_hours = ""
payload["month_hours"] = cached_hours or stored_hours
try:
payload["monthly_target"] = int(getattr(account, "monthly_target", 0) or 0)
except (TypeError, ValueError):
+3
View File
@@ -507,6 +507,9 @@ def test_assemble_prefers_live_month_hours() -> None:
account.month_hours = "10"
assert assemble(account, {"month_hours": "68"})["month_hours"] == "68"
assert assemble(account, {})["month_hours"] == "10"
account.hours_month = "2026-10"
account.month_hours = "88"
assert assemble(account, {}, datetime(2026, 11, 2, tzinfo=CN_TZ))["month_hours"] == ""
def test_schedule_disabled_skips_window_until_started() -> None: