Class: StatusController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- StatusController
- Defined in:
- app/controllers/status_controller.rb
Constant Summary collapse
- LIMIT_TASKS =
200
Instance Method Summary collapse
- #nodes ⇒ Object
- #retry_task ⇒ Object
- #tag_values ⇒ Object
- #tags ⇒ Object
- #task_statuses ⇒ Object
- #tasks ⇒ Object
Instance Method Details
#nodes ⇒ Object
6 7 8 |
# File 'app/controllers/status_controller.rb', line 6 def nodes render json: Node.includes(:slots).order(name: :asc), each_serializer: StatusPanelNodeSerializer end |
#retry_task ⇒ Object
44 45 46 47 48 49 |
# File 'app/controllers/status_controller.rb', line 44 def retry_task @task = Task.find_by!(uuid: params[:uuid]) @task.force_retry! head :ok end |
#tag_values ⇒ Object
39 40 41 42 |
# File 'app/controllers/status_controller.rb', line 39 def tag_values @tag = TaskTag.find_by!(name: params[:tag_name]) render json: @tag.values.take(50) end |
#tags ⇒ Object
30 31 32 33 |
# File 'app/controllers/status_controller.rb', line 30 def @tags = TaskTag.pluck(:name) render json: @tags end |
#task_statuses ⇒ Object
35 36 37 |
# File 'app/controllers/status_controller.rb', line 35 def task_statuses render json: Task.all_status end |
#tasks ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/status_controller.rb', line 10 def tasks limit = params.fetch(:limit, LIMIT_TASKS).to_i @tasks = Task .only(Task.attribute_names - %w[logs]) .includes(:slot) .order_by("created_at" => "desc") .batch_size(limit) .limit(limit) @tasks = @tasks.where(status: params[:status]) if params[:status].present? if params[:tags] params.require(:tags).each do |tag, value| @tasks = @tasks.where("tags.#{tag}" => value.to_s) end end render json: @tasks, each_serializer: StatusPanelTaskSerializer end |