Skip to content

JobClosedEvent

EventType: JOB_CLOSEDDomain: production Broker subject: progress.notification.production

Closes a job by running the COMPLETE_JOB AQL macro, which sets stage → CLOSED, records qt_completed, and writes notes and end timestamp. Removes the job from the assigned operator's queue. Spawned as a child of BatchCompletedEvent when the final batch is confirmed.

Sequence Diagram

Trigger

Triggered by: POST /event (universal event dispatcher)

Spawned as a child event by BatchCompletedEvent in backend/api/events/production/batch_completed.py when the completed quantity meets the work order requirement. Also dispatched directly via POST /event with event_type: JOB_CLOSED for manual force-close flows.

Preconditions

  • Job exists with key info.job_key
  • Job has an assigned_to value (queue removal depends on this)

State Changes (Transaction)

Collections: Job, Queue, WorkOrder, Task

  • Job updated via COMPLETE_JOB AQL: stage → CLOSED, qt_completed, notes, end
  • Queue entry removed for completed_job.assigned_to

Side Effects (post_processing)

JobClosedEvent extends BaseEvent directly (not BaseProductionEvent), with _notification_subtopic = "production" set explicitly. Publishes to progress.notification.production after commit.

InfoModel Fields

FieldTypeDescription
job_keystrArangoDB key of the job to close
completed_qtfloatFinal quantity declared as completed
update_planned_qtboolWhether to update the planned quantity to match completed
phase_keystr | NonePhase key (resolved from job)
work_order_keystr | NoneWork order key (resolved from job)
notesstr | NoneClosing notes (defaults to "Job closed")

None.

Source

JobClosedEvent on GitHub

Released under the Apache 2.0 License.