Sha256: 7de37b077df2dc7525203085710d8d897ab20e8efade0f9811f109f2ed91cb7c

Contents?: true

Size: 792 Bytes

Versions: 11

Compression:

Stored size: 792 Bytes

Contents

class Marty::JobController < ApplicationController
  def download
    job_id = params['job_id']

    promise = Marty::Promise.find_by(id: job_id)

    if promise
      format = promise.cformat

      # Force result so finalized object is built
      data = promise.result(true)

      # somewhat hacky: if result has "result" key, it's used as the
      # content.
      data = data['result'] || data
      title = promise.title
    else
      format = 'json'
      data = { error: "Job not found: #{job_id}" }
      title = 'error'
    end

    res, type, disposition, filename =
      Marty::ContentHandler.export(data, format, title)

    send_data(res,
              type:        type,
              filename:    filename,
              disposition: disposition,
             )
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
marty-14.3.0 app/controllers/marty/job_controller.rb
marty-14.0.0 app/controllers/marty/job_controller.rb
marty-13.0.2 app/controllers/marty/job_controller.rb
marty-11.0.0 app/controllers/marty/job_controller.rb
marty-10.0.3 app/controllers/marty/job_controller.rb
marty-10.0.2 app/controllers/marty/job_controller.rb
marty-10.0.0 app/controllers/marty/job_controller.rb
marty-9.5.1 app/controllers/marty/job_controller.rb
marty-9.5.0 app/controllers/marty/job_controller.rb
marty-9.3.3 app/controllers/marty/job_controller.rb
marty-9.3.2 app/controllers/marty/job_controller.rb