scinote-web/app/controllers/api/v1/task_groups_controller.rb

35 lines
940 B
Ruby
Raw Normal View History

2018-09-06 21:38:48 +08:00
# frozen_string_literal: true
module Api
module V1
2018-10-07 01:53:31 +08:00
class TaskGroupsController < BaseController
2018-09-06 21:38:48 +08:00
before_action :load_team
before_action :load_project
before_action :load_experiment
2018-09-13 15:25:16 +08:00
before_action :load_task_group, only: :show
2018-09-06 21:38:48 +08:00
def index
task_groups = filter_timestamp_range(@experiment.my_module_groups).page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: task_groups, each_serializer: TaskGroupSerializer, include: include_params
2018-09-06 21:38:48 +08:00
end
def show
render jsonapi: @task_group,
2018-10-07 01:53:31 +08:00
serializer: TaskGroupSerializer,
include: :tasks
2018-09-06 21:38:48 +08:00
end
private
2018-09-13 15:25:16 +08:00
def load_task_group
@task_group = @experiment.my_module_groups.find(params.require(:id))
2018-09-06 21:38:48 +08:00
end
def permitted_includes
%w(tasks)
end
2018-09-06 21:38:48 +08:00
end
end
end