Commit Graph
4 Commits
Author SHA1 Message Date
objecttothis 90e68714f0 feat(jobs): add batch-level import context and queue pause support
- Add import_batch_contexts table plus ImportBatchContext model so
  per-batch data (e.g. Items CSV attribute definitions) is stored
  once and referenced by context_id, instead of duplicated into
  every queued row's job payload.
- Extend queue_jobs, queue_jobs_failed, and new queue_paused_jobs
  tables with batch_id/context_id columns and FKs (ON DELETE
  RESTRICT) back to import_batch_contexts, so context rows cannot
  be purged while any job still references them.
- Introduce ImportBatchService.pushRow() to centralize queuing a
  batch row with batch/context stamping and priority; update
  Customers and Items controllers to use it instead of calling
  importBatch->create() and queue->push() separately.
- Add queue_paused_jobs table and Jobs::postPauseJobs()/pauseQueues()
  to move pending jobs out of queue_jobs into a paused table per
  queue (all core queues or a selected subset), leaving in-flight
  jobs untouched (issue #3833 pause/resume design).
- Change Jobs::getEditJob()/postSaveJob() routes to accept separate
  source/id path segments instead of a combined uid string.
- Add test coverage for ImportBatchContext, ImportBatchService, and
  ImportBatch (including purge-retains-while-referenced guards).

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-10-01 16:07:04 +04:00
objecttothis 5bd466d57b feat(jobs): add Jobs Manage grid CRUD and requeue actions
Extend Jobs controller to support full lifecycle management of
queued/failed jobs from the Manage tab UI.

- Add getView/postSave to edit a pending/reserved job's payload,
  priority, and available_at via modal (job_edit view)
- Add getSearch to back the AJAX-driven jobs table, using new
  JobQueueManage model for search/sort/pagination and payload
  decoding
- Add postDelete to bulk-delete pending/failed jobs, blocking
  deletion of reserved (in-progress) jobs
- Add postProcessJob to manually run a single job immediately,
  requeuing failed jobs back into queue_jobs first via new
  requeueFailedJob helper
- Add splitUid helper to parse "source:id" row identifiers shared
  across the new endpoints
- Extend queue_jobs_failed migration with attempts column since
  codeigniter4/queue's DatabaseHandler::failed() doesn't carry it
  over; BoundedQueueWorker now records it on failure so Manage
  grid can show real error counts

BREAKING CHANGE: queue_jobs_failed table gains required attempts
column; run new migration before deploying.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-10-01 12:04:36 +04:00
objecttothisandClaude Sonnet 5 4fa7db6da7 feat(jobs): add background job queue execution engine
Adds the queue_jobs, queue_jobs_failed, and job_throttles tables and wires
up BoundedQueueWorker (deadline-bounded queue draining, shared by the
JobRunner filter for web/auto mode and the manual "Process Jobs" UI) gated
by JobThrottleGate. Adds retry limit, retention, and auto-purge settings
to the Job Queue settings tab, and a manual per-queue processing UI on the
Utilities tab. Also adds a second-granularity throttle period and
BaseOsposJob as the shared base for core queue jobs.

This is issue #3833 Phase 2 — no real job types are queued yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-24 20:00:27 +04:00
objecttothis 8e6032a285 feat(jobs): add jobs module with throttling and config keys
- Register jobs module, permission, and admin grant so it
  appears in menu/ACL (20260916000000_AddJobsModule.php)
- Add job_throttles table to support rate-limiting job runs
  (20260916000001_CreateJobThrottles.php)
- Seed app_config with jobs_mode and jobs_web_max_seconds
  defaults for web-based job execution
  (20260916000002_AddJobsConfigKeys.php)
- Drop redundant FK re-add in fix_keys_for_db_upgrade migration
  that duplicated an already-existing constraint

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