Skip to content

The agent that grows with you

refactor(cron): count skipped runs in cron_status, not behind a report flag

kshitijk4poor9d093008b40a
diff --git a/hermes_cli/cron.py b/hermes_cli/cron.py
index 61eeea5b5c6..78ee266e618 100644
--- a/hermes_cli/cron.py
+++ b/hermes_cli/cron.py
@@ -177,7 +177,7 @@ _STATE_BADGES = {"paused": ("[paused]", Colors.YELLOW), "completed": ("[complete
def cron_list(show_all: bool = False):
"""List all scheduled jobs."""
from cron.jobs import effective_job_state, list_jobs
- store_report = _store_unwritable_report(count_skipped=False) # the one-line banner omits it
+ store_report = _store_unwritable_report()
jobs = list_jobs(include_disabled=True)
if not show_all:
jobs = [
@@ -413,16 +413,12 @@ def _ticker_age_is_fresh(age: Optional[float]) -> bool:
return age is not None and age <= TICKER_INTERVAL_SECONDS * 3 + 20
-def _store_unwritable_report(count_skipped: bool = True) -> Optional[dict]:
+def _store_unwritable_report() -> Optional[dict]:
"""Probe the active cron store (never a marker inside it): ``None`` when it accepts writes.
Runs before any job read: loading jobs re-secures the dir, which can mask a mode problem."""
- from cron.jobs import _current_cron_store, list_jobs
+ from cron.jobs import _current_cron_store
from cron.store_health import probe_report
- report = probe_report(_current_cron_store().cron_dir)
- if report is not None and count_skipped:
- report["skipped"] = sum(1 for j in list_jobs(include_disabled=False)
- if (_next_run_overdue_seconds(j.get("next_run_at")) or 0) > 0)
- return report
+ return probe_report(_current_cron_store().cron_dir)
def _print_store_unwritable(report: dict, *, brief: bool = False) -> None:
@@ -507,6 +503,8 @@ def cron_status():
print()
if (store_report := _store_unwritable_report()) is not None:
+ store_report["skipped"] = sum(1 for j in list_jobs(include_disabled=False)
+ if (_next_run_overdue_seconds(j.get("next_run_at")) or 0) > 0)
_print_store_unwritable(store_report)
print()
provider = _active_cron_provider_name()