Fix GET /tasks/:id/inputs, GET /tasks/:id/outputs endpoints

This commit is contained in:
Luka Murn 2018-10-07 11:35:12 +02:00
parent 239b974fa0
commit fca580face
2 changed files with 8 additions and 24 deletions

View file

@ -7,7 +7,7 @@ module Api
before_action :load_project
before_action :load_experiment
before_action :load_task, only: :show
before_action :load_task_relative, only: %i(outputs output inputs input)
before_action :load_task_relative, only: %i(inputs outputs)
def index
tasks = @experiment.my_modules
@ -21,18 +21,6 @@ module Api
render jsonapi: @task, serializer: TaskSerializer
end
def outputs
outputs = @task.my_modules
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: outputs, each_serializer: TaskSerializer
end
def output
output = @task.my_modules.find(params.require(:id))
render jsonapi: output, serializer: TaskSerializer
end
def inputs
inputs = @task.my_module_antecessors
.page(params.dig(:page, :number))
@ -40,9 +28,11 @@ module Api
render jsonapi: inputs, each_serializer: TaskSerializer
end
def input
input = @task.my_module_antecessors.find(params.require(:id))
render jsonapi: input, serializer: TaskSerializer
def outputs
outputs = @task.my_modules
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: outputs, each_serializer: TaskSerializer
end
private

View file

@ -579,14 +579,8 @@ Rails.application.routes.draw do
resources :results, only: %i(index create show),
path: 'results',
as: :results
get 'inputs',
to: 'my_modules#inputs'
get 'inputs/:id',
to: 'my_modules#input'
get 'outputs',
to: 'my_modules#outputs'
get 'outputs/:id',
to: 'my_modules#output'
get 'inputs', to: 'tasks#inputs'
get 'outputs', to: 'tasks#outputs'
resources :activities, only: %i(index show),
path: 'activities',
as: :activities