fix: 立即开始只在当月有效,密码被拒后不再重试
This commit is contained in:
@@ -433,6 +433,8 @@ def _refresh_one(employee_id: str, attempts: int, client_factory) -> None:
|
||||
account = db.get(Account, employee_id)
|
||||
if account is None or account.refresh_paused or not account.credential_cipher:
|
||||
return
|
||||
if account.credential_valid is False:
|
||||
return
|
||||
client = None
|
||||
valid = False
|
||||
checked_alive = False
|
||||
|
||||
@@ -12,9 +12,9 @@ class StudyControlError(ValueError):
|
||||
"""任务控制参数不符合要求。"""
|
||||
|
||||
|
||||
def start_now(account) -> None:
|
||||
def start_now(account, now: datetime | None = None) -> None:
|
||||
account.study_paused = False
|
||||
account.study_stop_month = ""
|
||||
account.study_stop_month = month_key(now)
|
||||
account.study_ignore_window = True
|
||||
|
||||
|
||||
@@ -63,19 +63,26 @@ def hours_met(account, now: datetime | None = None) -> bool:
|
||||
|
||||
|
||||
def expire_pause(account, now: datetime | None = None) -> bool:
|
||||
"""本月停止不影响下月定时。遗留的无月份暂停记到当月。"""
|
||||
if not bool(getattr(account, "study_paused", False)):
|
||||
return False
|
||||
"""本月的停止和立即开始都不带到下月。遗留的无月份暂停记到当月。"""
|
||||
key = month_key(now)
|
||||
recorded = str(getattr(account, "study_stop_month", "") or "")
|
||||
changed = False
|
||||
if ignores_window(account) and recorded and recorded != key:
|
||||
account.study_ignore_window = False
|
||||
changed = True
|
||||
if not bool(getattr(account, "study_paused", False)):
|
||||
if changed:
|
||||
account.study_stop_month = ""
|
||||
return changed
|
||||
if not recorded:
|
||||
account.study_stop_month = key
|
||||
return True
|
||||
if recorded != key:
|
||||
account.study_paused = False
|
||||
account.study_stop_month = ""
|
||||
account.study_ignore_window = False
|
||||
return True
|
||||
return False
|
||||
return changed
|
||||
|
||||
|
||||
def eligible(account, now: datetime | None = None) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user