Commit Graph
3 Commits
Author SHA1 Message Date
objecttothis 14b06eea30 feat(jobs): add task time warning threshold setting
Introduce a soft, log-only per-task time budget (jobs_task_max_seconds)
separate from the existing web request budget (jobs_web_max_seconds),
since PHP cannot preempt a running task mid-execution.

- Config: add taskMaxSeconds default (30s) to app/Config/Jobs.php
- Controller: validate and persist task_max_seconds in
  Jobs::postSaveSettings
- BoundedTaskRunner: accept taskMaxSeconds, measure task runtime via
  microtime, log a warning when a task exceeds the threshold
- JobRunner: read jobs_task_max_seconds from config and pass it to
  BoundedTaskRunner
- Migration: add AddJobsTaskMaxSecondsConfigKey to seed default
  app_config value
- Language: add en strings for label, validation message, and
  enabled/disabled tooltips
- View: add task_max_seconds form field to settings_config.php,
  wired to same web-mode enable/disable toggle as web_max_seconds
- Tests: update JobsControllerTest to cover new field in save/
  validation scenarios

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-09-23 13:22:16 +04:00
objecttothis 171dd056b3 fix(jobs): validate all throttles before saving any
Bug: saveThrottles validated and saved throttles in same loop.
Invalid entry mid-loop stopped processing but left already-saved
throttles committed, and omitted throttles could still get deleted
via notToDelete tracking — partial/inconsistent state on failure.

- app/Controllers/Jobs.php: split into two passes — validate all
  throttleData entries first; on any invalid entry, roll back
  transaction and return failure immediately before touching DB.
  Only save/delete once full payload validated. Drop now-redundant
  $success flag folded into invalid-entry early return.
- tests/Controllers/JobsControllerTest.php: add test asserting
  existing throttles stay unchanged in DB when payload contains
  invalid throttle data.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-09-17 16:22:55 +04:00
objecttothis f2b73fda36 test(jobs): add controller and model test coverage
Add PHPUnit tests for Jobs feature to lock in current
behavior before further changes.

- JobsControllerTest: covers /jobs index render, saveSettings
  validation (invalid mode, non-natural max_seconds) and
  success path, saveThrottles save/soft-delete-missing/invalid
  period handling, throttles partial render, and stub
  processAllJobs/processSelectedJobs endpoints
- JobThrottleModelTest: covers exists(), saveValue() insert vs
  update, getAll() excluding soft-deleted rows, and delete()
  soft-delete behavior

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-09-17 15:14:10 +04:00