Class: RcrewAI::Rails::ExecutionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rcrewai/rails/executions_controller.rb

Instance Method Summary collapse

Instance Method Details

#cancelObject



23
24
25
26
27
28
29
30
# File 'app/controllers/rcrewai/rails/executions_controller.rb', line 23

def cancel
  if @execution.running?
    @execution.cancel!
    redirect_to @execution, notice: 'Execution was cancelled.'
  else
    redirect_to @execution, alert: 'Execution cannot be cancelled.'
  end
end

#indexObject



6
7
8
9
10
11
# File 'app/controllers/rcrewai/rails/executions_controller.rb', line 6

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(20)
end

#logsObject



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

def logs
  @logs = @execution.execution_logs
  @logs = @logs.where(level: params[:level]) if params[:level]
  @logs = @logs.recent.limit(params[:limit] || 100)
  
  respond_to do |format|
    format.json { render json: @logs }
    format.turbo_stream
  end
end

#showObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/rcrewai/rails/executions_controller.rb', line 13

def show
  @logs = @execution.execution_logs.recent.limit(50)
  
  respond_to do |format|
    format.html
    format.json { render json: execution_json }
    format.turbo_stream if request.headers["Turbo-Frame"]
  end
end