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

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

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

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#cancelObject


54
55
56
# File 'app/controllers/aker/jobs_controller.rb', line 54

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

#completeObject


50
51
52
# File 'app/controllers/aker/jobs_controller.rb', line 50

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
25
26
27
28
29
30
31
# 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


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/aker/jobs_controller.rb', line 33

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