Class: Aker::JobsController

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

Overview

Provide index and show actions to display jobs inside Sequencescapew, and start, complete and cancel endpoints to change the status of the jobs from the inbox application

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #clean_params_from_check, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Instance Method Details

#cancelObject


44
45
46
# File 'app/controllers/aker/jobs_controller.rb', line 44

def cancel
  _finish_action("#{@job.aker_job_url}/cancel")
end

#completeObject


40
41
42
# File 'app/controllers/aker/jobs_controller.rb', line 40

def complete
  _finish_action("#{@job.aker_job_url}/complete")
end

#indexObject


10
11
12
# File 'app/controllers/aker/jobs_controller.rb', line 10

def index
  @jobs = Aker::Job.paginate(page: params[:page], per_page: 10).order(created_at: :desc)
end

#showObject


14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/aker/jobs_controller.rb', line 14

def show
  recover_from_connection_refused do
    @aker_job = JSON.parse(RestClient::Request.execute(
      verify_ssl: false,
      method: :get,
      url: @job.aker_job_url.to_s,
      headers: { content_type: :json },
      proxy: nil
    ).body)['job']
  end
end

#startObject


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/aker/jobs_controller.rb', line 26

def start
  recover_from_connection_refused do
    response = RestClient::Request.execute(
      verify_ssl: false,
      method: :put,
      url: "#{@job.aker_job_url}/start",
      headers: { content_type: :json },
      proxy: nil
    )

    render json: response.body, status: :ok
  end
end