fix: use is_job_runnable/effective_job_state in remaining pause-check sites

Two claim-failure diagnostic paths (cronjob_tools.py:629,921) still used
the old inline 'not enabled or state==paused' check. After get_job()
normalizes via effective_job_state, a half-paused record has
state='scheduled' and enabled=True, so the inline check returned False —
mislabeling the job as 'already being fired' instead of 'paused/disabled'.

Also hoists effective_job_state/is_job_runnable to the top-level import in
cronjob_tools.py (was function-local) and updates console_engine.py's
_format_job to use effective_job_state instead of the old inline
state-or-enabled derivation — a fourth display path the original PR missed.

Follow-up to PR #81287.
This commit is contained in:
kshitij
2026-08-08 13:42:06 +05:30
parent c7a5de7d6e
commit 2ddd24ec1f
2 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -148,9 +148,11 @@ def _format_sessions(sessions: Sequence[dict]) -> str:
def _format_job(job: dict, action: str) -> str:
from cron.jobs import effective_job_state
job_id = job.get("id") or job.get("job_id") or "?"
name = job.get("name") or "(unnamed)"
state = job.get("state") or ("scheduled" if job.get("enabled", True) else "paused")
state = effective_job_state(job)
return f"{action} job: {name} ({job_id}) [{state}]"