Class: GroundControl::Inertia::JobsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ground_control/inertia/jobs_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/ground_control/inertia/jobs_controller.rb', line 6

def index
  status = params[:status]
  jobs = ActiveJob.jobs.where(**@job_filters).with_status(status)
  page_obj = MissionControl::Jobs::Page.new(jobs, page: params[:page].to_i, page_size: GroundControl::Api.page_size)

  job_class_names = begin
    ActiveJob.jobs.with_status(status).job_class_names
  rescue
    []
  end

  queue_names = ActiveJob.queues.map(&:name)

  render inertia: page("jobs/index"), props: {
    jobs: serialize(GroundControl::Api::PageResource.new(page_obj, inner_resource_class: GroundControl::Api::JobResource)),
    meta: {
      status: status,
      filters: @job_filters,
      job_class_names: job_class_names,
      queue_names: queue_names
    },
    features: adapter_features
  }
end

#showObject



31
32
33
34
35
36
37
# File 'app/controllers/ground_control/inertia/jobs_controller.rb', line 31

def show
  job = ActiveJob.jobs.find_by_id(params[:id])

  render inertia: page("jobs/show"), props: {
    job: serialize(GroundControl::Api::JobResource.new(job))
  }
end