Class: ResultsController

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) index



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/results_controller.rb', line 5

def index
  if result_params[:test_id].present?
    @results = Result::Fetcher.fetch_by_test_id result_params[:test_id], JSON.parse(result_params[:query])
  elsif result_params[:task_id].present?
    @results = Result::Fetcher.fetch_by_task_id result_params[:task_id], JSON.parse(result_params[:query])
  elsif result_params[:task_run_id].present?
    @results = Result::Fetcher.fetch_by_task_run_id result_params[:task_run_id], JSON.parse(result_params[:query])
  elsif result_params[:user_id].present?
    @results = Result::Fetcher.fetch_by_user_id result_params[:user_id], JSON.parse(result_params[:query])
  else
    @results = []
  end

  render json: @results, status: :ok
end