Class: ResultsController

Inherits:
ApplicationController show all
Includes:
QueryVersionSupport
Defined in:
app/controllers/results_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::ALLOWABLE_CONFIGS

Instance Method Summary collapse

Methods included from QueryVersionSupport

#query_versions, #retrieve_query_version

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/results_controller.rb', line 34

def create
  interaction = Interaction::ResultCreation.new(result_params)
  result = interaction.execute

  if interaction.errors.any?
    render json: interaction.errors, status: :unprocessable_entity
  else
    Resque.enqueue(QueryExecution, result.id, current_user.role)
    render json: result, status: :created
  end
end

#destroyObject



25
26
27
28
29
30
31
32
# File 'app/controllers/results_controller.rb', line 25

def destroy
  respond_to do |format|
    format.json do
      @result.destroy!
      render json: @result
    end
  end
end

#indexObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/results_controller.rb', line 8

def index
  respond_to do |format|
    format.html
    format.json do
      @results = @query_version.results.accessible_by(current_ability)
      render json: @results
    end
  end
end

#showObject



18
19
20
21
22
23
# File 'app/controllers/results_controller.rb', line 18

def show
  respond_to do |format|
    format.html { render :index }
    format.json { render json: @result }
  end
end