Skip to content

Show each running job's average duration in the Settings Active processes list - #244

Merged
alfwro13 merged 2 commits into
mainfrom
feature/active-job-average-duration
Oct 11, 2026
Merged

alfwro13 merged 2 commits into
mainfrom
feature/active-job-average-duration

Conversation

@alfwro13

@alfwro13 alfwro13 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • The Settings → System Updates & Power Active processes list now shows each running job's average duration beside its running time, e.g. (running 3 min · avg 12m 5s).
  • scheduler_run_log.avg_duration_sec changes from an exponential moving average (alpha 0.3) to the plain mean of the job's last 20 successful runs in scheduler_run_history. The Workflow Monitor reads the same column, so both surfaces show one number. Failed runs are excluded; a job with no successful run keeps its previous value.
  • db_helpers.refresh_job_average_duration() is the single calculation: called after every recorded run and once in migrate_db() so existing moving-average values are replaced at upgrade.
  • GET /api/system/active-jobs gains active_job_avg_sec (same keys as active_jobs, null when no history). _mark_job_started() takes an optional job_id so the ETF predictor, Account Price Scraper and Account Auto Top-up jobs, whose names are built per account, resolve their own history; other jobs resolve through their canonical label.
  • The 20-run window is now constants.SCHEDULER_RUN_HISTORY_LIMIT, used by the history read, the average and the weekly prune.

Test plan

  • pytest tests/test_scheduler_engine.py tests/test_01_database_schema.py tests/test_02_api_get_endpoints.py tests/test_03_api_post_endpoints.py tests/test_accounts_api.py tests/test_accounts_engine.py tests/test_maintenance_engine.py tests/test_risk_orchestrator_engine.py (771 passed)
  • Visual check on the Settings page while a job is running
  • Note: the Workflow Monitor's overlap-risk conflict check now compares against this mean instead of the moving average, so its warnings may shift slightly.
  • Note: CSS_VERSION is 5.157 here; Show a Restart pending banner in Settings when the pulled code is newer than the running service #243 sets 5.156, so whichever merges second needs a one-line conflict resolution on that line.

@alfwro13
alfwro13 merged commit 5431f69 into main Oct 11, 2026
5 checks passed
@alfwro13
alfwro13 deleted the feature/active-job-average-duration branch October 11, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant