class CanvasSync::JobBatches::ChainBuilder

def enqueue_job(job_def)

> [DONE] Use a Lua script to find child batch IDs. Support max_depth, items_per_depth, top_depth_slice parameters
> UI will map Batches to Chain-steps using the chain_step_id. UI will add entries for any Chain-steps that were not tied to a Batch
> Using server-middleware, if a Chain-job (has chain_id and chain_step_id) creates a Batch, tag the Batch w/ the chain_id and chain_step_id
> Chain-jobs will be supplied chain_id and chain_step_id metadata
> If augmented with Chain data, the above will be annotated with Chain-related info and will be able to show Jobs defined in the Chain
> [DONE] Tree view w/o Chain will only show Parent/Current batches and Job Counts
Augment Batch tree-view with Chain data
TODO: Add a Chain progress web View
def enqueue_job(job_def)
  job_class = job_def[:job].constantize
  job_options = job_def[:parameters] || []
  # Legacy Support
  if job_def[:options]
    job_options << {} unless job_options[-1].is_a?(Hash)
    job_options[-1].merge!(job_def[:options])
  end
  if job_class.respond_to? :perform_async
    job_class.perform_async(*job_options)
  else
    job_class.perform_later(*job_options)
  end
end