Sha256: 159bb4cf6fb28a057a0c80e72845f862dfb37bd7da554fc802a136fa35a2cf52

Contents?: true

Size: 433 Bytes

Versions: 4

Compression:

Stored size: 433 Bytes

Contents

# frozen_string_literal: true

module SqlMonitor
  class ExplainSqlController < ActionController::Base

    def not_found
      respond_to do |format|
        format.any  { head :not_found }
      end
    end

    def index
      return not_found if Rails.env.production?

      data = ActiveRecord::Base.connection.execute("EXPLAIN #{params[:sql]}").first
      render json: {
        result: data.to_json
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sql_monitor-0.1.3 app/controllers/sql_monitor/explain_sql_controller.rb
sql_monitor-0.1.2 app/controllers/sql_monitor/explain_sql_controller.rb
sql_monitor-0.1.1 app/controllers/sql_monitor/explain_sql_controller.rb
sql_monitor-0.1.0 app/controllers/sql_monitor/explain_sql_controller.rb