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

View file

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