Class: RcrewAI::Rails::Api::V1::ExecutionsController

Inherits:
RcrewAI::Rails::ApplicationController show all
Defined in:
app/controllers/rcrewai/rails/api/v1/executions_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



9
10
11
12
13
14
15
16
# File 'app/controllers/rcrewai/rails/api/v1/executions_controller.rb', line 9

def index
  @executions = Execution.includes(:crew)
  @executions = @executions.where(crew_id: params[:crew_id]) if params[:crew_id]
  @executions = @executions.where(status: params[:status]) if params[:status]
  @executions = @executions.recent.limit(params[:limit] || 50)
  
  render json: @executions.as_json(include: :crew)
end

#logsObject



35
36
37
38
39
40
41
# File 'app/controllers/rcrewai/rails/api/v1/executions_controller.rb', line 35

def logs
  @logs = @execution.execution_logs
  @logs = @logs.where(level: params[:level]) if params[:level]
  @logs = @logs.recent.limit(params[:limit] || 100)
  
  render json: @logs.as_json(only: [:id, :level, :message, :details, :timestamp])
end

#showObject



18
19
20
21
22
23
# File 'app/controllers/rcrewai/rails/api/v1/executions_controller.rb', line 18

def show
  render json: @execution.as_json(
    include: :crew,
    methods: [:duration_seconds]
  )
end

#statusObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/rcrewai/rails/api/v1/executions_controller.rb', line 25

def status
  render json: {
    id: @execution.id,
    status: @execution.status,
    started_at: @execution.started_at,
    completed_at: @execution.completed_at,
    duration_seconds: @execution.duration_seconds
  }
end