Class: RailsVitals::ExplainsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_vitals/explains_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/rails_vitals/explains_controller.rb', line 3

def show
  @record = RailsVitals.store.find(params[:request_id])
  return render plain: "Request not found", status: :not_found unless @record

  @query_index = params[:query_index].to_i
  query = @record.queries[@query_index]
  return render plain: "Query not found", status: :not_found unless query

  @sql = query[:sql]
  @binds = query[:binds] || []
  @result = Analyzers::ExplainAnalyzer.analyze(@sql, binds: @binds)
end